How do cookie and cache values ​​expire?

Expiration values ​​always confuse me, as client time settings can be completely different from server settings. I would like to know what is going on behind the scenes.

Say my server time zone is GMT +1 and my time zone is GMT + 2. If now I create a cookie with expiration: current_timestamp + 31 * 86400 (expires after 31 days), how does the browser know the correct time? The expiration time is converted to GMT values, and then the browser converted to the correct client time zone? Or should they always be in GMT?

Caching time probably has the same mechanism, if not please clarify.

+1
cookies
source share
2 answers

Cookie expires headers are in a format that includes the time zone, so there is no ambiguity as to when the cookie expires.

http://www.cookiecentral.com/faq/#3.2

 Set-Cookie: foo=bar; path=/; expires Mon, 09-Dec-2002 13:46:00 GMT 
+3
source share

You can also convert it to universal time conversion using the .toUTCString method

+1
source share

All Articles