← Glossary

What Are Persistent Cookies?

Persistent cookies are HTTP cookies given an explicit lifetime through the Expires or Max-Age attribute, so the browser keeps them across restarts until that time passes. The stated lifetime is a ceiling, not a promise, because browsers, users and servers can all remove them earlier.

Updated:

Persistent cookies are cookies that carry an expiry instruction. When a server includes an Expires date or a Max-Age duration in a Set-Cookie header, an accepting browser can retain the cookie beyond the current session and return it with matching requests until that moment arrives, surviving tab closures and browser restarts along the way. A cookie without either attribute is a session cookie, which the browser discards when it decides the session has ended. The word persistent describes the intention encoded in the header, and that is all it describes. Nothing in the attribute guarantees the cookie will still exist tomorrow: the server can overwrite it, the user can delete it, and the browser can cap or discard it under its own policies. Understanding persistent cookies means understanding both how the lifetime is set and how often reality falls short of it.

Expiration Attributes and How They Are Stored

Two attributes control lifetime, and they express the same idea in different forms. Expires takes an absolute timestamp in HTTP date format, for example Expires=Sat, 06 Nov 2027 09:00:00 GMT. Max-Age takes a number of seconds counted from when the browser receives the cookie, for example Max-Age=31536000 for one year. MDN notes that Expires has been available longer but that Max-Age is less error-prone and takes precedence when both are present. The reason is clock skew: an absolute date is interpreted relative to the client's clock, and a client with a wrong clock expires the cookie at the wrong time, whereas a relative duration does not depend on the client's idea of the current date. Firefox and Chromium-based browsers compensate for skew on Expires by comparing against the Date response header.

In ordinary browsing, an accepted persistent cookie can be saved in the browser's cookie store, indexed by name, domain, path and, in newer implementations, partition key. On each later request the browser checks the request URL against those scope attributes and against the cookie's Secure and SameSite settings, includes the cookie if everything matches and the expiry has not passed, and silently drops it once the expiry is reached. Expired cookies are never sent.

Updates, Deletion and Browser Policies

A persistent cookie's lifetime can be changed at any time by the server that owns it. Sending a new Set-Cookie with the same name, domain, path and applicable partition replaces the cookie and its expiry; sending Max-Age=0 or a negative value, or an Expires date in the past, deletes it immediately. Many sites refresh long-lived cookies on every visit, which is why a consent banner's cookie or a remember-me token can appear to live forever: each visit resets its clock.

Users can delete cookies through browser settings, extensions and private browsing modes that normally discard their cookies when the private session ends. Browsers also impose ceilings and cleanup of their own. Specific caps on how far in the future an expiry may be set, and heuristics that shorten script-set cookies or clear storage for sites the user has not interacted with, exist in current browsers and vary by vendor and version; the maximum effective lifetime of a cookie is therefore the smaller of what the server asked for and what the browser permits, and both change over time. Analytics vendors increasingly document this: Matomo's cookie documentation, for example, lists a 13-month default expiry for its visitor cookie while warning that some browsers delete cookies earlier after periods of inactivity. A server that needs a stable long-term value should treat the cookie as a hint to be renewed, not a guarantee.

Persistent Cookies Compared With Session Cookies

AspectSession cookiePersistent cookie
Expiry attributesNoneExpires or Max-Age, with Max-Age winning if both appear
Survives browser restartNormally no, though session restore can preserve itYes, until the expiry or earlier deletion
Who decides when it endsThe browser's definition of a sessionThe server's stated time, bounded by browser policy and user action
Typical contentServer session identifiersPreferences, consent records, remember-me tokens, analytics identifiers

The persistent vs session cookies distinction is about declared lifetime only. Both kinds carry the same scope and security attributes, both are subject to SameSite rules, and both can be first-party or third-party. The boundary is also blurrier than it looks: MDN points out that browsers using session restore can keep session cookies indefinitely, so a session cookie is not reliably short-lived either. What a server controls is the instruction it sends; what happens afterwards is governed by the client.

What Persistent Cookies Are Used For

The classic purposes are remembering choices and recognising returning visitors. A language or region preference, a dismissed notice, a consent decision, and a theme setting can use persistent cookies when the server needs those choices on the first request of a later visit; client-only preferences may instead use browser storage. Remember-me functionality stores a long-lived token that lets the site establish a new session without a password; that token should be separate from the session identifier, revocable on the server, and stored with Secure and HttpOnly. Analytics and advertising systems use persistent first-party cookies to tell new visitors from returning ones and to count users across visits, which is the use that attracts privacy regulation and consent requirements in many jurisdictions. A login is not required to set a persistent cookie, although a remember-me credential is associated with an authenticated account.

Limits and Misconceptions

Persistent does not mean permanent. The lifetime is a maximum set by the server and trimmed by browsers and users, and a cookie that was expected to last a year may be gone in days on a browser with aggressive cleanup or on a device whose user clears data regularly. Persistent also does not mean tracking. A language value alone need not distinguish one visitor from another, while a short-lived session token can link requests to a known account. Consent records may also contain identifiers, so their purpose does not automatically make them anonymous. Whether a cookie tracks depends on what it contains and who reads it, not on its expiry. Finally, a persistent cookie is only as trustworthy as its contents: an unsigned preference can be edited by the user, and a long-lived token that is not bound to a revocable server record becomes a standing credential. Treating expiry as a ceiling, verifying values server-side, and handling absence rather than assuming continuity are the habits that make persistent cookies behave as intended.

Frequently asked questions

Can a persistent cookie be deleted early?

Yes. The server can overwrite it with a past expiry or Max-Age of zero, the user can clear cookies or use a private window, and browsers apply their own caps and cleanup heuristics. The stated expiry is the latest the cookie can live, not a guarantee.

What if Expires and Max-Age disagree?

Max-Age takes precedence when both valid attributes are present. It expresses a relative duration rather than an absolute date and avoids relying on agreement between the server and client clocks. Browsers may also compensate Expires values using the response Date header.

Are persistent cookies always tracking cookies?

No. Persistence only describes requested lifetime. A language value may not distinguish visitors, while an analytics identifier or consent record can do so. Tracking depends on the data and how it is used, rather than the expiry attribute alone.

Do persistent cookies require a login?

No. Preferences, consent records and analytics identifiers are stored in persistent cookies for visitors who never sign in. Remember-me tokens are one login-related use among many.

How long can a persistent cookie last?

The server requests a lifetime, but browser caps, user clearing, private-session rules and other policies can shorten it. Refreshing an expiry on a later visit does not override those controls. Applications should work correctly when the cookie is missing.