# First-party cookie

Also called: first-party cookies, 1st party cookie

A first-party cookie is a cookie that belongs to the domain of the site you are visiting, set either by that site's server or by a script running on its pages. It keeps you logged in, holds a cart or remembers settings, and analytics tools also use it to recognise returning visitors.

## How it is calculated

The browser compares the cookie's domain with the site in the address bar. On `shop.example`, a cookie for `shop.example` or a subdomain of it is first-party, whoever's script wrote it. That last point matters: an analytics or ad script running on your page can write a first-party cookie, and it then works across visits to your site but not across other sites.

First-party is not the same as exempt from consent. In the EU the [ePrivacy rule](/glossary/eprivacy-directive) asks whether storing the cookie is strictly necessary for a service the visitor asked for, not who set it: a login or cart cookie usually is, an analytics cookie usually is not. Browsers also limit some first-party cookies. WebKit's [tracking prevention documentation](https://webkit.org/tracking-prevention/) says Safari deletes cookies created in JavaScript, and other script-writable storage such as localStorage, after 7 days without user interaction with the site.

## Example

An analytics script writes `_id=93a1` as a first-party cookie on your domain with a 2-year expiry. A Chrome visitor who comes back after 30 days is counted as returning. A Safari visitor who comes back after 30 days with no visit in between has had the cookie deleted after 7 days, so the same script counts them as new. Over a quarter, the tool reports a lower share of returning visitors in Safari than in Chrome for the same audience.

## Common mistakes

- Assuming first-party cookies never need consent. Under EU ePrivacy rules what matters is whether the cookie is strictly necessary, not whose domain it is on.
- Trusting long expiry dates. Safari caps script-set cookies, so a 2-year cookie may last 7 days.
- Calling a third-party tool's cookie first-party data and stopping there. If the vendor reads it to build profiles across its customers, it is used for tracking all the same.

## How CrispStats shows it

CrispStats sets no first-party cookies and, by default, writes nothing to the device. Visitors are counted with a daily rotating hash computed on the server, so the count does not depend on cookie lifetimes and does not differ between Safari and Chrome for that reason. The opt-in persistent visitor mode does store a random id in localStorage on your domain, which is script-writable storage subject to Safari's 7-day rule and should only be turned on with consent.

## Related terms

- [Third-party cookie](/glossary/third-party-cookie)
- [Cookie consent](/glossary/cookie-consent)
- [ePrivacy Directive](/glossary/eprivacy-directive)
- [Cookieless tracking](/glossary/cookieless-tracking)
- [Unique visitor](/glossary/unique-visitor)
- [First-party data](/glossary/first-party-data)
- [Visitor hash](/glossary/visitor-hash)
