Forum Moderators: coopster
SET cookie:
$value = 'value';
setcookie("TestCookie", $value);
setcookie("TestCookie", $value, time()+3600); /* expire in 1 hour */
CHECK cookie:
if(isset($HTTP_cookie_VARS['TestCookie'])){;
$cookievalue = $HTTP_cookie_VARS['TestCookie'];
}else{
$cookievalue = no_cookie;
}
echo "$cookievalue";
When I echo $cookievalue I get no_cookie. I can't find out what I am doing wrong. I have checked in firefox and the cookie exists.
setcookie("TestCookie", $value);
// CHECK cookie
if(isset($_COOKIE['TestCookie'])){;
// do something
}
Cookie is browser side thingy, so it will not be available in the $_COOKIE array until sent by the browser. So in example above cookie will become available only after page is accessed second time.
Cookie is browser side thingy, so it will not be available in the $_COOKIE array until sent by the browser. So in example above cookie will become available only after page is accessed second time.
Your saying if both the codes are in the same file, the cookie won't be 'seen' until the browser has been refreshed etc?
I am using setcookie.php and using a location header to checkcookie.php so (if I understand you right) this isn't an issue for me. - just clariying.
Cheers guys.