Find out cookie expiration date with javascript

I use functions to create and read cookies from quirksmode.org/js/cookies.html. I have also set expiration days. I would like to know the expiration date of the cookie ... so I can tell the visitor how many days he / she should wait until something else is possible == until the cookie is automatically erased.

thanks

+7
javascript cookies
source share
2 answers

Hmm, there seems to be no easy way to do this. JavaScript can only access name / value pairs, not additional information that can be set in a cookie.

After some searching, the closest thing to the solution I could find (technically this is a workaround) is that if you really need to have a cookie expiration date, then you can save it in another cookie. When you formulate an 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

+4
source share

Unable to retrieve this information.

All you can get on the client side is the document.cookie property, a single line consisting of name-value pairs. Other details are not available to the customer.

+4
source share

All Articles