question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Why `Max-Age` cookie attribute is not used instead of a hairy `Expires` attribute

See original GitHub issue

To my surprise, I failed to find existing issue on that, so I keep wondering why Max-Age cookie attribute is not used instead of Expires as defined by RFC6265?

I use a recommended cookie.maxAge option in my project, but still the cookie I see in unit tests has Expires: <date>.

I believe Max-Age was invented to solve an obvious issue with (historically older) Expires attribute: that is, dates on server and client generally don’t match due to time zones. So, it is impossible to control on server how exactly client will interpret the date sent.

Also please expire asap command from server seems easier to do with Max-Age=-1 (or any value, <=0, per spec) than with Expires: Thu 02 Feb 1970 12:34:3 (can you say that latter is correct at all?).

The only drawback I found is that IE 6/7/8 do not support it. But most of us don’t care anymore, right? For those who cares Expires can be send, additionally (unlocked by a settings flag?).

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Pavekcommented, Feb 3, 2017

@dougwilson, thanks for reply.

To contribute to this discussion, I found this pretty decent cookie compat table: https://inikulin.github.io/cookie-compat/ The situation in general is pretty bad – who knew Cookie is such a nut… 😃

One particular test case confirms that no recent IE/Edge versions support "foo=bar; max-age=-1" for cookie expiry.

0reactions
dougwilsoncommented, Feb 6, 2017

Thanks for that information, @Pavek , very helpful 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

chromium / external / github.com / jjlee / mechanize ...
this value from the Max-Age attribute). discard: boolean, true if this is a session cookie; (if no expires value,. this should be true)....
Read more >
Browser Security Handbook, part 2 - Google Code
A much less commonly used, but RFC-mandated max-age= parameter might be used to specify expiration time delta instead. Overwriting cookies: if a new...
Read more >
Jigsaw Overview - W3C
(20030214) Cache is not used when a no-store directive is present in the request; (20030214) Overflow in Max-Forward leads to an exception and...
Read more >
Browser language detection is not cache aware - Drupal
So, the patch does not avoid cache kill, instead it introduces language redirect. (Which in D7 was usually performed by globalredirect ...
Read more >
GNU Wget 1.21.1-dirty Manual
Enable use of file system's extended attributes to save the original URL and the ... does not normally carry session cookies, Wget marks...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found