A cookie is a small piece of data that a website asks your browser to store and then send back on later requests. Consent rules, which vary by country, decide when a site may store or read such data on your device without asking you first.
What is a cookie, exactly?
The web’s basic protocol, HTTP (Hypertext Transfer Protocol), is stateless: each request is handled on its own, with no built-in memory of the one before. Cookies are the standard workaround. According to the Internet Engineering Task Force (IETF), the standards body that maintains the protocol specifications, cookies let servers “maintain a stateful session over the mostly stateless HTTP protocol.”
The mechanism is simple. A server includes a Set-Cookie header in its response. The browser, which the standard calls a user agent, stores the value and returns it in a Cookie header on later requests to the same site. That is how a shop remembers what is in your basket, or how a service knows you are still logged in after you move from one page to another. For background on how requests travel across the network in the first place, see our explainer on how the internet works.
A cookie is not a program. It cannot run code or scan your files. It is a short name-and-value pair, plus some instructions about where and for how long it applies. The privacy concern is not what a cookie is but what it can be used to link together: if the same identifier is sent back across many visits, or across many sites, it can build a record of behavior.
How do cookies work behind the scenes?
A cookie carries attributes that control its scope and lifetime. The IETF’s current draft revision of its cookie specification, which updates the long-standing RFC 6265, describes these:
| Attribute | What it does |
|---|---|
| Domain | Sets which hosts receive the cookie. If omitted, the cookie goes back only to the server that set it. |
| Path | Limits the URL paths where it is sent. The draft warns that this “cannot be relied upon for security.” |
| Expires / Max-Age | Sets a lifetime, either as a date or as a number of seconds. If both appear, Max-Age takes precedence. |
| Secure | Sends the cookie only over a secure channel, typically HTTPS. |
| HttpOnly | Keeps the cookie away from scripts running in the page. |
| SameSite | Controls whether the cookie is sent on cross-site requests (values Strict, Lax or None). |
A cookie with no expiry is a session cookie and normally disappears when the browser session ends. One with an expiry is persistent. The draft recommends that the limit “SHOULD NOT be greater than 400 days” in the future, and says browsers are not required to keep a cookie until its stated date, since they may evict cookies under memory pressure or for privacy reasons.
There are size limits too. According to the draft, a cookie whose name and value together exceed 4,096 octets (bytes) is ignored, and browsers may cap storage, with 50 cookies per domain and 3,000 in total given as examples. These are guidance for implementers, and real browsers can differ.
First-party and third-party cookies: why the difference matters
A first-party cookie is set by the site you are visiting. A third-party cookie is set by a different domain whose content is embedded in that page, such as an advertising network, a social widget or an analytics provider. Because the same third party may be embedded on thousands of sites, its cookie can recognize you across all of them. That cross-site recognition is what drew most regulatory attention.
The IETF draft acknowledges that a browser may leave out the Cookie header on third-party requests and may block cookies set in them. The SameSite attribute exists partly for this: a cookie marked Strict or Lax cannot be set in response to a cross-site subresource request. Browser vendors decide their own defaults, and those defaults have shifted over time, so the behavior you see depends on which browser and version you use.
Cookies are also not the only technique. Other browser storage and device-recognition methods can do similar work. That is one reason the legal rules are written in terms of storing or accessing information on a device rather than naming cookies alone.
Why do websites ask for cookie consent?
The banners are a response to law, not to the web standard. Several jurisdictions regulate storing information on a user’s device or reading it back. The UK government’s factsheet on its Data (Use and Access) Act describes the baseline in the Privacy and Electronic Communications Regulations (PECR): storing or accessing information on a user’s terminal equipment, meaning their phone, laptop or other device, “remains prohibited” unless an exception applies. One exception is that the user has given consent. Another covers storage that is strictly necessary to deliver a service the user asked for.
In the European Union the equivalent rule sits in the ePrivacy Directive, which is separate from the General Data Protection Regulation (GDPR). Where cookie data also counts as personal data, the GDPR’s standard for valid consent applies as well. In broad terms, that standard means consent must be a genuine, informed choice, not a pre-ticked box or silence.
The practical result is the familiar banner: a site that wants to use non-essential cookies is expected to explain what they do and wait for a choice before setting them.
Which cookies need consent, and which do not?
Regulators generally separate cookies by purpose rather than by technical type.
- Strictly necessary cookies. These support something the user has asked for and that would not work without them, such as keeping items in a basket or maintaining a login during a session. They are generally exempt from consent requirements.
- Preference cookies. Remembering a language or layout choice is useful, but whether it is exempt depends on the rules in each place.
- Analytics cookies. These measure how a site is used. Treatment is changing in the UK, discussed below.
- Advertising and cross-site tracking cookies. These are the central target of consent rules and normally require a prior opt-in where consent rules apply.
A common misconception is that a banner is needed because a site “uses cookies.” The legal test is about purpose and about whether an exception applies. A site that sets only strictly necessary cookies may not need a consent prompt at all, though it may still have to provide information about them.
What is changing in the UK, and what is still uncertain?
The UK is mid-change. According to the government factsheet on the Data (Use and Access) Act, existing PECR exceptions are retained, and a new exception is added for using cookies or similar technologies to collect statistical information about how an organization’s online services are used, with the aim of improving the service. The Secretary of State can also add or amend exceptions through secondary regulations after consulting the Information Commissioner’s Office (ICO) and other interested groups.
The factsheet states that the Act “will come into force in stages,” with exact dates to be published on GOV.UK. The factsheet gives no exact dates and no maximum fine figures, so readers should check the current commencement position and the ICO’s guidance before relying on any specific date or penalty. The factsheet also does not spell out every condition attached to the new analytics exception, so how narrowly it will be read in practice remains to be seen.
What is the difference between accepting, rejecting and “managing” cookies?
For a visitor, the choices on a banner map to real differences.
- Accept all allows every category the site lists, including advertising and tracking.
- Reject all or “necessary only” should leave only exempt cookies in place. Whether the site actually honors that is a compliance question, not something the banner proves.
- Manage preferences lets you switch categories on or off individually.
Rejecting cookies does not stop a site from knowing your IP address, which is part of the connection itself. It also does not delete cookies already stored. To remove those, use your browser’s settings, where you can usually clear them per site or in bulk. Clearing cookies will typically sign you out of services and reset preferences.
Common mistakes and myths about cookies
- “Cookies are viruses.” They are inert data. The risk lies in what they enable linking, and in what an attacker could do with a stolen session cookie, which is why the Secure and HttpOnly attributes matter.
- “Blocking all cookies is safe and free.” Many sites rely on them for basic function, so blanket blocking can break logins and checkouts.
- “Consent banners protect me automatically.” A banner records a choice; it does not by itself prove the site respected it.
- “The rules are the same everywhere.” They are not. The EU and UK frameworks are related but separate, and other countries and US states have their own, differently structured privacy laws.
- “A cookie lasts as long as the site says.” The IETF draft makes clear that browsers may evict cookies earlier and are encouraged to cap lifetimes.
Site operators can reduce exposure by reviewing what is actually being set, avoiding unnecessary third-party embeds and using secure transport. Our piece on shorter TLS certificate lifetimes covers one part of the secure-connection picture, and the explainer on content delivery networks shows how third-party infrastructure ends up in the request path.
Where cookie rules and browser behavior are heading
Two forces are pulling in the same direction. Browsers keep tightening what third parties can do by default, and legislators are adjusting which low-risk uses should need a prompt. The UK’s new statistical-purposes exception is an example of the second trend: it reflects a view that some measurement is less intrusive than advertising tracking.
For readers, the useful mental model is simple. A cookie is a labeled note a site asks your browser to keep. The standard defines how that note travels, and the law defines when a site may ask. Because the law differs by place and is still changing in places such as the UK, the banner you see today may not be the one you see in a year.
This article offers general information, not legal advice or a substitute for professional compliance advice.
Sources: Internet Engineering Task Force; GOV.UK



