COOKIE is before the content of the web page is sent. Send the message first. That is to say. There cannot be any HTML code, echo, etc. before this, even a space is not allowed. .
Cookies are placed before web content is sent. Send the message first. That is to say. There cannot be any html code, echo, etc. before this, even a space is not allowed. .
In the PHP tutorial, you need to use the setcookie function to register the cookie variable. Your code above does not register the cookie variable. How could it possibly be delivered? The correct way to write it is as follows:
*/
$status=0;
if(isset($_cookie['mytstcky'])&&($_cookie['mytstcky']=="chocchip")) $status=1; //If the variable has been set
if(!isset($_get['cchk'])) //If the variable is not set
{
setcookie("mytstcky","chocchip"); //Send cookie information
header("location:$php_self?cchk=1"); //Send header
exit; //End php code
}
?>