The value of $_COOKIE is determined by the content of cookies received in the user agent's request.
If you set a cookie (ie send it to the browser), it won't be sent back until the next request and so the data won't be present in $_COOKIE.
User Contributed Notes
$_COOKIE
$_COOKIE
Chris Watson
30-Sep-2009 12:18
30-Sep-2009 12:18
Sam Yong - hellclanner at live dot com
05-Sep-2009 02:27
05-Sep-2009 02:27
Take note that in IE when it's really weird that when you do something like this:
<?php
// import config/constants
session_set_cookie_params((time()+$_SITE['session_length']));
session_start();
$sess = session_name();
setcookie($sess, $_COOKIE[$sess], time() + $_SITE['session_length']);
// .. rest of the code
?>
It fails. the session cookie is not stored totally.
Instead, doing this would work:
<?php
// import config/constants
session_set_cookie_params((time()+$_SITE['session_length']));
session_start();
$sess = session_name();
setcookie($sess, session_id(), time() + $_SITE['session_length']);
// .. rest of the code
?>