<?php
$product1 = "user";
if(!isset($_COOKIE[$cookie_name])) {
$value=1;
echo "Cookie named '" . $product1 . "' is not set!";
setcookie($product1, $value, time() + (86400 * 30), "/");
} else {
echo "Cookie '" . $product1 . "' is set!<br>";
echo "Value is: " . $_COOKIE[$product1];
$value=$_COOKIE[$product1];
setcookie($product1, $value, time() + (86400 * 30), "/");
}
?>
//即使在刷新页面后,我仍然收到名为user的消息cookie。请帮忙
答案 0 :(得分:0)
$product1 = "user";
//print_r($_COOKIE);
if(!isset($_COOKIE[$product1])) {
$value=1;
echo "Cookie named '" . $product1 . "' is not set!";
setcookie($product1, $value, time() + (86400 * 30), "/");
} else {
echo "Cookie '" . $product1 . "' is set!<br>";
echo "Value is: " . $_COOKIE[$product1];
$value=$_COOKIE[$product1];
setcookie($product1, $value, time() + (86400 * 30), "/");
}