A cookie is a small file a website asks a browser to store, so the same visitor can be recognised on the next page or the next visit. It is the oldest mechanism on the web for remembering anything, it underpins logins and baskets as much as advertising, and the two kinds of cookie now have very different futures.
In short
- A cookie is a small file a browser stores on a site’s behalf.
- First-party cookies come from the site you are on and still work.
- Third-party cookies come from elsewhere and are largely blocked.
- Browsers now shorten expiry dates, so measurement decays faster than it used to.
What a cookie actually is
The mechanism is simpler than the debate around it suggests.
A site sends a small piece of text to the browser, usually little more than a name and a random identifier. The browser stores it and sends it back on every subsequent request to that same site. That is the whole trick: the site does not remember you, it hands you a ticket and reads it when you return.
Most cookies contain nothing meaningful in themselves. The identifier is matched against records held on a server, which is where the information actually lives. A cookie stolen from a browser is a cloakroom ticket rather than a coat.
The name causes more confusion than the mechanism. People assume a cookie is a program, or that it can read files, or that it follows them by itself. It does none of those things. It is a piece of text handed back and forth, and everything interesting happens on the server that reads it.
They are also load-bearing for ordinary things. Staying logged in, keeping a basket between pages, remembering a language choice, and stopping a form being submitted twice all rely on them. The argument is about what else they are used for, not about whether they should exist.
First-party and third-party
The distinction is about which domain set the cookie, and it decides almost everything about whether it still works.
A first-party cookie is set by the domain in the address bar. It lets that site recognise a returning visitor, which is how a session is stitched together and how analytics knows one person viewed four pages, as opposed to four people viewing one.
A third-party cookie is set by a different domain loaded inside the page: an advertising network, an embedded video, a widget. Because the same network appears on many sites, it can recognise the same browser across all of them. That is what made following somebody around the internet possible, and it is what browsers have spent years restricting.
Safari has blocked third-party cookies by default for years, Firefox does the same, and the effect on retargeting has been arriving gradually rather than on any announced date. Treat any plan that depends on third-party cookies as a plan with a short remaining life.
How long one lasts
Expiry used to be the site’s decision and now it is a negotiation.
A session cookie has no expiry date and disappears when the browser closes. A persistent cookie carries one, and a site can ask for a year or more.
What changed is that browsers no longer honour long expiry dates unconditionally. Cookies set by a script rather than by the server are capped sharply in some browsers, measured in days where the site asked for months. The practical result is that a returning visitor who was recognised for a year in 2018 may be treated as brand new after a week, which inflates visitor counts and shortens the window in which any conversion can be attributed.
Serving measurement from your own domain, not a supplier’s, helps, though not completely, and the arrangement and its limits are covered under CNAME record.
What breaks when they are blocked
The failures are uneven, which is what makes them confusing.
- Visitor counts inflate. One person across three devices and two cleared browsers is several users, always has been, and is more so now.
- Attribution windows shorten. A purchase two weeks after the advert cannot be connected to it if the cookie expired after seven days.
- Retargeting audiences shrink. Fewer browsers can be recognised, so the pool of people you can reach again is smaller than the traffic suggests.
- Cross-device paths vanish entirely. Somebody who researched on a phone and bought on a laptop is two unrelated strangers.
None of this makes measurement useless. It makes it a sample rather than a census, and reports should be read that way. The direction of a number remains reliable long after its absolute value stops being.
This is also why two tools never agree. Analytics counts what the browser was allowed to tell it, an advertising platform counts what it recognises inside its own apps, and your shop counts orders that actually completed. Three vantage points, three numbers, and only the last one is money.
Consent is a separate question
Whether a cookie can be set at all, and when, is not a technical matter.
Anything beyond what the site strictly needs to function is supposed to wait until the visitor has answered, and the mechanics of asking properly are covered on the consent banner page, including what has to be true for an answer to count.
One technical trap belongs here rather than there. Holding a script back until consent is given does not help if the page still opens a connection to that supplier in advance. A preconnect or preload hint reaches the third party before anybody has pressed anything, silently, and it is easy to leave behind when a script is put behind a gate. If you gate something, check the hints too.
Words you will hear
- First-party cookie. Set by the site you are visiting.
- Third-party cookie. Set by another domain inside the page, and mostly blocked.
- Session cookie. Disappears when the browser closes.
- Persistent cookie. Carries an expiry date, which browsers may shorten.
- Consent banner. The interface that asks before non-essential cookies are set.
- Essential cookies. The ones a site cannot function without.
- Consent Mode. Google’s arrangement for running tags in a restricted state until somebody answers.
Open your own site, look at the storage panel in your browser’s developer tools, and count what is set before you touch anything. Most businesses find more there than they expected, and some of it from suppliers they forgot they had added.
Questions we get
More about cookie
What is the difference between a first-party and a third-party cookie?
Are cookies the same as tracking?
How long does a cookie last?
If somebody declines the banner, do cookies still get set?
Will clearing cookies make us disappear from reports?
Do we need cookies for a simple website?
What replaces third-party cookies?
Related terms
Consent banner
A consent banner asks whether tracking and advertising scripts may run. Most are decorative, because they appear after the scripts have already loaded.
Session
A session is one visit to your website, grouped by analytics from separate events. It ends on a timer, which is why the number rarely matches reality.
Retargeting
Retargeting shows adverts to people who already visited your site. It reports the best numbers you run, partly by claiming people who were coming back anyway.