Document CookieStore.set() maxAge option#43353
Conversation
|
Preview URLs (2 pages) (comment last updated: 2026-03-09 19:13:21) |
| ### Setting a cookie with options | ||
|
|
||
| This example sets a cookie by passing an `options` object with `name`, `value`, `expires`, and `partitioned`. | ||
| This example sets a cookie by passing an `options` object with `name`, `value`, `maxAge`, and `partitioned`. |
There was a problem hiding this comment.
This is problematic, in particular because maxAge is less supported that expires. Is there a BCD?
There was a problem hiding this comment.
I've been going in circles about this issue a bit. You are right that it is problematic — afaics, it isn't that easy to feature detect whether a specific option from the options object is supported. For now, I've just put it back the way it was, to using expires.
There was a problem hiding this comment.
The BCD is at mdn/browser-compat-data#29197.
There was a problem hiding this comment.
Looks pretty good. Perhaps also add an update to https://developer.mozilla.org/en-US/docs/Web/API/CookieStore#setting_cookies to note that you can also use maxAge on browsers where it is supported? (and maybe a link to the set() browser compat)?
I've added this. |
hamishwillee
left a comment
There was a problem hiding this comment.
Thanks very much @chrisdavidmills - works for me
Description
Since version 145, Chrome has supported the
CookieStore.set()method'smaxAgeoption; see https://chromestatus.com/feature/5190778418757632.This PR documents the new option.
Motivation
Additional details
Related issues and pull requests