if( isset($_COOKIE["cl1"] ) )
{
echo $_COOKIE["cl1"];
}
else
{
setcookie("cl1","me",time()+ 3600);
}
if( isset($_COOKIE["cl1"] ) )
{
echo "the cookie is set";
}
When I run this page the page must 开发者_如何学编程show "the cookie is set" but the screen is empty. Why?
The cookie will not be available until the next page load. The cookie is sent with the page request. A hack to make it so that cookie value will be in the $_COOKIE array on the same page load would be:
setcookie("cl1","me",time()+ 3600);
$_COOKIE['cl1'] = "me";
精彩评论