Page 1 of 1

PHP Cookies

Posted: Tue Mar 16, 2010 11:01 am
by rohan.ckul
<?php $check=setcookie('cookie_test', 'please_accept_for_session1');
echo $HTTP_COOKIE_VARS['cookie_test'];
?>

Now, when I change the value of 'cookie_test', and refresh the browser page, it does not reflect the first time. It only reflects after a second fresh.

Any reasons ?

Re: PHP Cookies

Posted: Tue Mar 16, 2010 1:18 pm
by AbraCadaver
When you use setcookie() the cookie value ins't available until you refresh the page or on another page load. You should really be using $_COOKIE instead of $HTTP_COOKIE_VARS.