Trouble reading cookies
Posted: Sun Oct 08, 2006 12:22 pm
This a baffling problem for me, I have a script which creates a cookie to store someone's username, should they wish to the site to remember their username for next time they visit.
I can create the cookies, and they seem to be set correctly, I have checked Cookies directory for IE, and the cookie is there, in FireFox, I view the list of cookies, and again, the cookie is there.
The trouble seems to be accessing the cookie values. I have tried using $HTTP_COOKIE_VARS, and also $_COOKIE but not succeding, below is the code which attempts to read and display the cookie value :
I can't see what im doing wrong here, the code below is used to set the cookie :
$username is not empty, I have checked foor this, and the correct values are being written to the cookie, but I just cannot access them!
i hope someone can help with this
Musaffar
I can create the cookies, and they seem to be set correctly, I have checked Cookies directory for IE, and the cookie is there, in FireFox, I view the list of cookies, and again, the cookie is there.
The trouble seems to be accessing the cookie values. I have tried using $HTTP_COOKIE_VARS, and also $_COOKIE but not succeding, below is the code which attempts to read and display the cookie value :
Code: Select all
global $HTTP_COOKIE_VARS;
$username = $HTTP_COOKIE_VARS['username'];
print $username;Code: Select all
setcookie('username', $username, time()+99999);$username is not empty, I have checked foor this, and the correct values are being written to the cookie, but I just cannot access them!
i hope someone can help with this
Musaffar