anyone happen to know how to detect a cookie's expiration date?
Printable View
anyone happen to know how to detect a cookie's expiration date?
I don't think so, so I did a quick search on google, see if any of these are of any help:
http://www.google.com/search?q=detec...ient=firefox-a
It does not look like it is possible. I don't know for sure though. The best I was able to find was this thread: http://www.webmasterworld.com/php/3369153.htm
No, there is no way to read the cookie expiry date using a browser's javascript once it has been created UNLESS you add a separate entry into the cookie as a value-data pair as you would do for any other saved data - the expiry date is not given back by the browser because it is considered a security issue. You must be executing code coming from the creator domain to read cookie data anyway, so the cookie must belong by you therefore you already have the full control to add whatever data you need to retrieve later as you see fit. This technique is commonly used by yahoo's cookies, etc. to make the date available, and is often called 'age'.
Java (not javascript) does have a class constructor and method getMaxAge(), but the feedback comes from the browser, so it will return -1 for not set, meaning good only for the session life, and returns 0 for set to a future date (If I remember correctly).
Thanks for the explanation :). I can view the expiration of the cookies if I use Opera, so that's one option. I have not tried the other browsers yet.
Just add the expiry date of the cookie when creating it.