PHP-da cookie-fayllarni qanday qilib olish mumkin?

Cookie faylini PHPda olishni xohlayman. Cookie qiymati emas! Quyidagi kabi kodim:

<?php
session_start();
ob_start();

$user_id = $_GET["user_id"];
$timing_clock = "";

if(isset($_COOKIE["timing_type"])){
 //cookie's value  
  $timing_clock = setcookie("timing_type");
//how to get cookie's name?
} else {
   echo("0");
}
?>

Qanday qilaman? Cookie-ning nomini o'zgaruvchiga o'rnatishni xohlayman. Cookie faylining nomi men uchun juda muhim.

0
var_dump ($ _ COOKIE); bilan cookie fayllarini var_dump harakat qilib ko'ring
qo'shib qo'ydi muallif Jer, manba
PHP cookie-faylining mumkin bo'lgan dublikati mavjud emas va qiymatini o'rnatmagan bo'lsa
qo'shib qo'ydi muallif Rushil Pachchigar, manba

6 javoblar

sizga yordam beradi, var_dump ($ _ COOKIE) dan foydalaning va barcha COOKIE nomini oling.

$cookie_name = "user";
$cookie_value = "Dave";
setcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/"); 
if(isset($_COOKIE)) {
    var_dump($_COOKIE);
    foreach($_COOKIE as  $key => $val)
    {
      echo "cookie name = ".$key.", and value = ".$val;
    }
} 
2
qo'shib qo'ydi
@Javoiy: "Ha, javobni tahrir qildim.
qo'shib qo'ydi muallif Dave, manba
Bu qiymati qanday o'zgaruvchan qilib qo'yishim mumkin?
qo'shib qo'ydi muallif Jsawyer, manba

Bu barcha nomlar bilan chop etiladi


<?php print_r($_COOKIE); ?>


1
qo'shib qo'ydi

Setcookie tomonidan o'rnatilgan nomni olish uchun oddiygina $ _ COOKIE ["name"] ni o'qib chiqing

1
qo'shib qo'ydi

All cookies names are stored in $_COOKIE as "Name" => "value". Simply output the keys of the $_COOKIE array and you'll have your names :)

0
qo'shib qo'ydi

Setcookie() ning birinchi paramateri cookie nomi hisoblanadi

<?php
session_start();
ob_start();

$user_id = $_GET["user_id"];
$timing_clock = "";

if(isset($_COOKIE["timing_type"])){
 //cookie's value  
  $timing_clock = setcookie("timing_type");
 //how to get cookie's name?
  $cookie_name = $_COOKIE['timing_type'];

} else {
   echo("0");
}
?>
0
qo'shib qo'ydi

Ushbu misolda

setcookie("timing_type");

the cookie name would be $_COOKIE['timing_type']

Setcookie funktsiyasidan foydalanganda cookie nomini (kaliti) qo'llaymiz.

0
qo'shib qo'ydi
Javascript UZB
Javascript UZB
99 ishtirokchilar

@js_uzb @vuejs_uz @react_uz @nodejs_uz @angular_uz @ngTashkent @yiiframework_uz @laravel_uz @linux_uzbek @python_uz @swift_uzb —————— @uzdevgroup @UzGeeksGroup ——— @UzDev_Jobs @jobs_uzb

PhP |BotsUz
PhP |BotsUz
93 ishtirokchilar

Phpni o'rganishni Hohlasangiz https://t.me/joinchat/AAAAAE-KRc5dd5tPMmGmWA A'zo bo'lin