Skip to content

How long cookies last

← Known cookies

Every cookie has an end date. Three things decide when it really ends: the law of the visitor’s country, their browser, and how the tool is set up.

Browser

StatisticsMarketingPreferencesNecessaryWhere the visitor’s yes ends13 months: several authorities, such as the CNIL, recommend no longer for a tracking cookieCut back by the browser

Each dot is one of the 1,800 cookies of the 800 tools that Cookie Rocks recognises by name: statistics, ads, chats, videos, maps and more (the list). It sits at the duration its maker states, or the longest we saw on real WordPress sites. A real site uses only a few dozen of them: the free Audit lists yours.

The law sets how long a yes lasts

Many countries set how long a visitor’s choice may be kept before the site asks again. When the yes ends, the site must ask before it reads its cookies again.

Country by country, with the source of each figure: How long a choice lasts.

  • France6 months
  • Belgium6 months
  • Ireland6 months
  • Luxembourg12 months
  • Denmark12 months
  • Spain24 months

The yes lasts months. The cookie can stay for years.

The browser has the last word

Whatever date a site asks for, the browser can end a cookie sooner. A cookie written again at each visit gets a new date each time, so these limits count from the last visit.

  • Chrome and Edge: 400 days at most, since Chrome 104 (Chrome).
  • Firefox: 400 days too, since version 132 (Mozilla).
  • Safari: 7 days for a cookie written by a script; cookies sent by the server keep their date (WebKit).
  • Brave: 6 months for every cookie, since version 1.83 (Brave).
  • Safari, cookie written by a script7 days
  • Brave6 months
  • Chrome, Edge, Firefox400 days

The tool decides the rest

Many tools let the site owner choose how long their cookies last. The duration on a sheet is the default one: your site may use a shorter one.

  • CallRail: 6 months by default, or 30, 60, 90 days; the date moves forward at each visit.
  • Dynatrace: session cookies by default; 2 years with its user tracking switched on.
  • AWS WAF: a security check stays valid from 5 minutes to 3 days, as the site chooses.
  • AWS WAF5 minutes to 3 days
  • CallRail30 days to 6 months
  • Dynatracea session to 2 years

Things that trip people up

  • A date that keeps moving Many tools write their cookie again at each visit, with a new end date. A visitor who comes back every month keeps the same identifier for as long as they come back.
  • Session cookies that survive A session cookie ends when the browser ends the session. When it reopens the last tabs, as Chrome does with “Continue where you left off”, it brings them back too (MDN).
  • Storage with no end date Local storage has no date at all: it stays until the site or the visitor clears it, except in Safari. See Browser storage.
  • The choice and the cookies are two things The cookie that keeps the visitor’s choice has its own duration. When it ends, the banner shows again; the other cookies are still there.

Good habits

  • Keep each cookie no longer than its purpose needs. If a tool lets you shorten it, do.
  • Ask again when the yes ends, at the pace the visitor’s country sets.
  • When a visitor takes back their yes, delete the cookies and the storage it allowed.
  • Give the real durations in your cookie policy, not a single “up to 2 years” for everything.
  • Do not count on a browser to shorten a cookie for you: not every visitor uses that browser.
You make a plugin or a theme?Check your cookie and storage names before you ship. A name already taken, or too generic, gets sorted and blocked with someone else’s.
For plugin and theme developers →

What Cookie Rocks does

  • It keeps the visitor’s choice 6 months by default, 13 months at most. For each visitor, it shortens that to the strictest maximum of their country and of the country of your site.
  • After a no, it waits as long as the visitor’s country asks before showing the banner again.
  • When a choice takes back a yes given earlier, it deletes the matching cookies and browser storage, then reloads the page.
  • Your cookie policy lists each cookie with its own duration, from the cookies we know. A name we cannot place yet waits in the unidentified names.