Forum Moderators: coopster
How do I read the expiration time for a cookie? I understand that reading the value of a cookie is just $HTTP_COOKIE_VARS["CookieName"] but is there a way to read when it expires?
What I'm trying to do is make a login with a "remember me" option. So if you choose "remember me" the cookie is permanent, but if not it expires an hour after you are done with the admin section of the site.
So I need to keep updating the cookie to expire after an hour, but only if it is set to expire less than an hour from "now". (if that makes any sence at all)
$HTTP_COOKIE_VARS is deprecated so just use $_COOKIE instead
I'm glad you told me that, I thought it was the other way around!
So I tried printing out the cookie but it is just the text data either way I set it. I was just hoping for a quick way to check the expiration.
I guess the other thing I could do would be to use a session cookie instead for people that don't want to be logged in permanently.
setcookie ("CookieName", "", time() + 3600);
But I don't know if there is a way to find out how much time is left in the cookie itself. You might create parallely running script in the server to let you know how much is left.
Habtom
The only way around it which I can see is to set two cookies, one of which just contains the value of time()...
You can then check by if ($_COOKIE[mycookie_time]<(time()-3600))