PrivacyQuick

Cookies & tracking

Cookie lifespans: browser caps and regulator limits

A cookie lasts until its expiry date, but browsers and regulators both set limits. Chrome caps cookies at 400 days, Safari cuts many to 7 days, and regulators such as France's CNIL expect analytics cookies to last no more than 13 months.

  • Plain English
  • Written for website owners
  • Free to read

A cookie lives until the expiry date its creator sets, unless the browser or the user removes it sooner. Browsers now cap those dates: Chrome and other Chromium-based browsers shorten any cookie to at most 400 days, and Safari limits many cookies to 7 days or even 24 hours. Regulators add limits of their own. France's CNIL, for example, allows consent-exempt analytics cookies only if they last no more than 13 months. This guide covers both sets of limits and how to choose expiry dates that hold up.

A cookie's lifetime comes from two optional attributes on the Set-Cookie header or the document.cookie string:

  • Expires gives an absolute date and time.
  • Max-Age gives a number of seconds from now. If both are present, Max-Age wins.

A cookie with neither attribute is a session cookie. It's meant to disappear when the browsing session ends, though browsers that restore tabs on startup may keep it. A cookie with either attribute is a persistent cookie.

Set-Cookie: cart_id=8f3a91; Path=/; Secure; HttpOnly; SameSite=Lax
Set-Cookie: lang=de; Path=/; Max-Age=31536000; Secure; SameSite=Lax
Set-Cookie: promo_seen=1; Path=/; Expires=Wed, 31 Dec 2026 23:59:59 GMT; Secure

The first is a session cookie. The second lasts one year. The third ends at a fixed date. To delete a cookie, you set it again with Max-Age=0 and the same name, path and domain.

Many tools also refresh their cookies on every visit, rewriting them with a new expiry date. A "two-year" analytics cookie on a site someone visits weekly may never expire at all. That matters for regulators, as you'll see below.

Browser caps at a glance

BrowserLimitApplies to
Chrome, Edge and other Chromium browsers400 daysEvery cookie. Longer Expires or Max-Age values are shortened. Introduced in Chrome 104 (2022) and later applied to existing cookies.
Safari (ITP)7 daysCookies set by JavaScript through document.cookie.
Safari (ITP)24 hoursScript-set cookies when the visitor arrived from a domain ITP classifies as a tracker, with identifiers in the URL (link decoration).
Safari (ITP)7 daysServer-set cookies from responses that ITP treats as third-party in disguise, such as CNAME-cloaked tracking subdomains or servers on unrelated IP addresses.
Safari (ITP)7 days without interactionAll script-writable storage for a site, including localStorage and IndexedDB, is deleted after seven days of Safari use without the user interacting with that site.
FirefoxNo short blanket cap by defaultThird-party cookies are partitioned per site by Total Cookie Protection; check Mozilla's current documentation for any change.

Two details are easy to misread. Safari's seven days usually means seven days of browser use, not calendar days. And the 400-day figure comes from the current draft revision of the HTTP cookie standard, which recommends it as an upper limit and lets browsers choose a shorter one. Browser behavior changes, so as of late 2026, check the vendors' own release notes before you build analytics assumptions on any of these numbers.

What the caps mean in practice

The caps mostly affect analytics and advertising, because those rely on recognizing a returning browser:

  • Returning visitors look new. A Safari user who returns after more than seven days with a JavaScript-set analytics cookie is counted as a new user. That inflates user counts and weakens attribution.
  • Long-term settings disappear. A language or currency preference stored in a JavaScript cookie may reset for Safari users who visit rarely.
  • Consent may be asked again sooner. If your consent tool stores the visitor's choice in a JavaScript cookie, Safari may delete it after seven days, and the banner reappears. That's not a compliance problem, but visitors notice it.

Server-set first-party cookies from your own web server, on your own domain, are generally not shortened by ITP's seven-day rule. That's one reason server-side tagging has become popular. It doesn't change the consent requirement: a cookie set by your server for analytics still needs consent where the law requires it. The overview of Chrome's third-party cookie plans explains how browser policies and consent rules relate.

What regulators say about lifespans

The ePrivacy Directive doesn't set a maximum cookie lifetime. Limits come from the GDPR's principles and from national regulators' guidance:

  • Storage limitation. GDPR Art. 5(1)(e) says personal data must be kept no longer than necessary for its purpose. A cookie holding an identifier for five years needs a five-year purpose.
  • Transparency. In Planet49 (C-673/17, October 2019), the Court of Justice of the EU said the information given when asking for cookie consent must include the duration of the cookies and whether third parties can access them.
  • CNIL (France). For audience-measurement cookies that can be used without consent, the CNIL requires, among other conditions, that the cookie last no more than 13 months, that this period isn't extended automatically on new visits, and that the collected data is kept no more than 25 months. The guide to CNIL's cookie rules covers the full exemption.
  • AEPD (Spain). The Spanish regulator's cookie guide treats consent validity of no more than 24 months as good practice.
  • ICO (UK). The ICO doesn't set a number. It expects durations to be proportionate to the purpose and says a cookie shouldn't last longer than it needs to.

The CNIL's 13 months is the figure most often quoted as a general rule of thumb, partly because it's simple and partly because many organizations apply French guidance across Europe. It's a sensible default for analytics identifiers even outside France.

Short, fixed lifetimes are easier to defend than long, self-renewing ones. A 13-month analytics cookie that isn't refreshed on each visit meets the strictest common guidance and still covers year-over-year comparisons.

Lifespans of common cookies

Default lifetimes for widely used tools, as documented by the vendors at the time of writing:

CookieSet byDefault lifetimeNotes
_gaGoogle Analytics2 yearsRefreshed on each hit by default; Chrome caps it at 400 days.
_ga_<container-id>Google Analytics 42 yearsHolds session state for one GA4 property.
_gcl_auGoogle Ads (conversion linker)90 daysStores ad click information.
_fbpMeta Pixel90 daysRefreshed on visits.
Session ID (e.g. PHPSESSID)Your platformSessionUsually strictly necessary.

Vendors change these defaults, so check your own scan results. A cookie scanner records each cookie's actual expiry as set in a real browser, which can differ from documentation. PrivacyQuick's scanner does this and can feed the durations straight into the cookie table in your cookie policy.

Your own cookies

Set Max-Age to what the purpose needs. A dismissed promotional banner might need 30 days. A language preference might need a year. A cart for anonymous visitors might need a few days. Avoid "forever" values such as dates far in the future.

Google Analytics 4

The Google tag lets you change cookie expiry and stop automatic refreshing. This example sets roughly 13 months (395 days, in seconds) and turns off the refresh:

gtag('config', 'G-XXXXXXXXXX', {
  cookie_expires: 34128000,   // 395 days x 86,400 seconds
  cookie_update: false        // don't extend expiry on every visit
});

Turning off cookie_update means returning visitors keep the original expiry, so the identifier ends 13 months after the first visit. You'll see slightly more "new" users over time, which is the trade-off. In Google Tag Manager, set the same fields on the Google tag's configuration settings.

Third-party tools

Many vendors don't let you change their cookie lifetimes. Where they don't, record the vendor's actual durations in your cookie policy and make sure the tool runs only with consent. If a tool sets very long-lived identifiers you can't control, that's worth weighing when you choose vendors.

Your consent tool stores each visitor's choice, usually in a cookie or local storage, and that storage has its own lifetime. When it expires, the visitor sees the banner again. Regulators' expectations on how often to re-ask are a separate topic, covered in the guide to how long cookie consent lasts.

Keep one rule in mind: an analytics cookie shouldn't outlive the consent that allowed it for long. If you re-ask every 12 months, a two-year self-renewing analytics cookie can keep tracking someone who later refuses, unless you delete it when consent is withdrawn.

Checklist

  • List every cookie with its actual expiry, from a scan rather than vendor documentation alone.
  • Set your own cookies' Max-Age to what the purpose needs.
  • Limit analytics identifiers to about 13 months and stop automatic refreshing where you can.
  • Expect Safari to shorten JavaScript-set cookies and storage, and read your analytics accordingly.
  • State each cookie's duration in your cookie policy.
  • Delete or stop refreshing cookies when a visitor withdraws consent.

Frequently asked questions

What is the maximum lifespan of a cookie?

In Chrome and other Chromium browsers, 400 days: longer expiry dates are shortened to that. Other browsers have their own rules, and Safari shortens many cookies to 7 days or less.

Do session cookies expire when the browser closes?

Not always. A cookie without Expires or Max-Age is meant to end with the browsing session, but browsers that restore previous tabs on startup may keep session cookies alive across restarts.

Is cookie lifespan the same as how long consent lasts?

No. Cookie lifespan is how long a cookie stays in the browser. Consent duration is how long you rely on a visitor's choice before asking again, which is a separate decision, though the consent cookie's expiry usually enforces it.

Do I need to state cookie durations in my cookie policy?

Yes, in the EU. The Court of Justice said in Planet49 (2019) that the information given to users must include how long cookies operate, so list a duration for each cookie.

Check your own website in 30 seconds

Our free scanner lists every cookie and tracker your site sets, sorted into categories, before you add a banner.

Run a free cookie scan Start free

This guide is general information, not legal advice. Laws and regulator guidance change; check the current rules for your situation or ask a lawyer.