I am setting a cookie with a user's username with the following code at the top of a login page:
setcookie ("myusername", $username,time() + 3600);
At the top of each additional page, i check to see if the cookie is set before i show the page. So I do something like the following:
if ($myusername)
{
//show page in here
}
else
{
echo("You must log in");
}
This is supposed to last one hour. However, randomly, at various times, I will receive the "You must log in" message. This happends sparatically. Sometimes the cookie lasts the whole hour, and sometimes it doesn't even last 5 minutes..
Does anyone know why this might be happening? Or what I can do to find out how the cookie is disappearing? Or maybe why the script isn't detecting the cookie at these random times?
Thanks.