What does the 'Max-Age' cookie attribute specify, and how does it differ from 'Expires'?
- A.Max-Age specifies the number of seconds until the cookie expires (relative to when the cookie is set). Expires specifies an absolute date/time. Max-Age takes precedence when both are present. Max-Age is preferred because it avoids clock synchronization issues - the browser's local clock may differ from the server's, causing Expires to behave unpredictably
- B.Max-Age specifies an absolute date (a UTC value) for the cookie to expire, with Expires counting seconds from the moment the cookie is set. Expires usually takes precedence when both are present, since the specification places the older attribute first, a rule that clients follow in current releases of each major browser engine on desktop devices running current releases
- C.Max-Age specifies the idle time in seconds after the last request (a sliding value), with Expires setting a fixed date. Max-Age is often ignored by browsers when the cookie is HttpOnly, since scripts do not refresh it, a quirk that explains why servers send both attributes together in the same header line for each cookie, a pairing that proxies also keep intact when they cache the response