BF50 Black Friday · 50% off all plans
from $5/mo · Auto-applied ---:--:-- Claim 50% off →
Skip to content

Search Seonio

Type a keyword, domain, or paste a URL

Start free with $1 to see full results. Powered by Seonio
Web Development

Cookie: What it is and how websites use it

A cookie is a small piece of data a website stores in your browser. How cookies work, first- vs third-party, consent, and what they mean for analytics.

Monthly searches · cookie
3.4m
Keyword research data
cookie
Cookie: What it is and how websites use it
Click the image to view it full size

A cookie is a small piece of text that a website asks your browser to keep. On every later request to that site, the browser sends it back. That's how a site remembers you're signed in, what's in your cart or which language you picked, even though each page load is a separate request.

For marketers and site owners, cookies matter for a second reason: analytics, ad measurement and remarketing depend on them, and privacy rules decide when you may set them.

How cookies work

The server sends a Set-Cookie header with a name and a value. The browser stores it and returns it in a Cookie header on later requests to the same site. Scripts on the page can read and write cookies too, through document.cookie, unless the cookie is marked HttpOnly (MDN).

Set-Cookie: session_id=7yjgj57e4n3d; Secure; HttpOnly; SameSite=Lax

Sites use cookies for three jobs:

  • Sessions: sign-in status, carts, half-filled forms.
  • Preferences: language, theme and other settings.
  • Tracking: recording what people do, on one site or across sites.

Cookies are small by design. The standard, RFC 6265, asks browsers to support at least 4,096 bytes per cookie and at least 50 cookies per domain (RFC 6265). Because they travel with every request, MDN recommends Web Storage or IndexedDB for data that only the browser needs.

First-party and third-party cookies

A cookie is first-party when it belongs to the site in the address bar. It's third-party when it comes from another site, usually through something embedded in the page, such as an ad, a video player or a social widget.

Third-party cookies make cross-site tracking possible, so browsers limit them (MDN):

Browser Third-party cookies by default
Firefox Kept in a separate cookie jar per site (Total Cookie Protection)
Safari Blocked by Intelligent Tracking Prevention
Chrome Allowed, unless the user blocks them or uses Incognito

Google had planned to phase out third-party cookies in Chrome. On October 17, 2025, it said Chrome will keep letting users choose instead, and it retired most Privacy Sandbox APIs, including Topics and Protected Audience (Privacy Sandbox blog). The history of that plan is in third-party cookie deprecation. Since Safari and Firefox already limit cross-site tracking, measurement that depends on third-party cookies misses part of your audience anyway.

  • Session cookies have no Expires or Max-Age. The browser deletes them when the session ends, though browsers that restore tabs can keep them much longer.
  • Persistent cookies last until the date in Expires or for the number of seconds in Max-Age. If both are set, Max-Age wins. To delete a cookie, send it again with Max-Age=0.
Attribute What it does
Secure Sent only over HTTPS
HttpOnly Hidden from JavaScript, which limits the damage of cross-site scripting
Domain If set, the cookie also goes to subdomains; if left out, only to the host that set it
Path Sent only for URLs under this path; not a security boundary
SameSite Strict, Lax or None: whether the cookie goes along on cross-site requests
Partitioned Keeps a third-party cookie in a separate jar per top-level site

A cookie without SameSite is treated as Lax, and SameSite=None only works together with Secure.

Partitioned comes from CHIPS (Cookies Having Independent Partitioned State). An embedded service, such as a chat widget, can keep a cookie for each site it's embedded on, but can't read that cookie on other sites. Partitioned cookies must be Secure (Privacy Sandbox). Google kept CHIPS when it retired the other APIs, citing its broad adoption; Firefox and Safari support it as well.

Laws such as the EU's GDPR and ePrivacy Directive and the California Consumer Privacy Act apply to many sites outside their home countries. MDN sums up the typical requirements: tell users your site uses cookies, let them opt out of some or all of them, and let them use most of your service without them. A consent banner does this in practice: it holds back non-essential cookies, such as analytics and advertising, until the visitor agrees. Which cookies count as essential for your site is a question for your legal advisor.

Cookies and your analytics

Google Analytics 4 uses first-party cookies. _ga tells users apart and _ga_<container-id> keeps session state; both last two years by default. Browsers can cut that short: Google notes a cap of 400 days in Chrome and 7 days in Safari for visitors who don't come back (Google Analytics Help). So some "new users" in your reports are returning people whose cookie expired.

When visitors decline cookies, consent mode tells Google tags to adjust. With analytics_storage or ad_storage denied, the tags write no cookies for that purpose. In advanced consent mode they send cookieless pings instead, which Google Analytics and Google Ads use to model behavior and conversions once a property collects enough data (Google tag platform).

Do cookies affect SEO?

Not directly. Google's renderer clears cookies between page loads and declines permission requests (Google Search Central). Content that only appears after a cookie is set, for example after a consent click, may not be what Google sees. Make sure your main content loads without any cookie.

Cookies or local storage?

Cookies go to the server with every request and can be hidden from scripts. Local storage stays in the browser, holds more data and can only be read by scripts on the page. Use cookies for what the server needs, such as a sign-in session, and local storage for what only the page needs.

Seonio

Put it to work on your own site

Keyword research, traffic, backlinks and clustering in one place. Start with a free $1 to test, no card required.