views:

311

answers:

2

Hi, I use functions for creating and reading cookies from quirksmode.org/js/cookies.html. I set also days to expire. I would like to find out cookie's expiry date ... so I can tell visitor how many days he/she must wait until something is possible again == until cookie is automatically erased.

thanks thanks

+2  A: 

Hmm, there doesn’t seem to be an easy way to do this. JavaScript can only access the name/value pairs rather than the additional info that can be set in a cookie.

After some searching, the closest thing to a solution I could find (technically it is a workaround) is that if you really need to have the expiration date of a cookie, what you can do is to store it in another cookie. When you formulate the expiration date, set it as the expiration date of your target cookie, and the value of another cookie.

For example, set NAME=BOB;expirationdate and NAME_EXP=expirateiondate;expirationdate

Synetech inc.
A: 

It is not possible to get this information.

All you can access client-side is the document.cookie property, a single string composed of name-value pairs. The other details are not accessible to the client.

Andrzej Doyle