---
title: "Cookie"
description: "A cookie is a small piece of text a website stores in your browser to remember a basket, sign-in or choice. Most UK cookies need consent first."
url: https://ursy.com/wiki/cookie/
updated: 2026-11-26T15:46:03+00:00
publisher: URSY (https://ursy.com/)
cite: Name URSY and link https://ursy.com/wiki/cookie/
---

# Cookie

> A cookie is a small piece of text a website stores in your browser to remember a basket, sign-in or choice. Most UK cookies need consent first.

**A cookie is a small piece of text that a website asks your browser to store and then send back with later requests, so the site can remember things such as a basket, a sign-in or a choice you made.** Cookies make the web feel joined up. In the UK, most of them also need the visitor’s consent before they are set, which is why the word matters for privacy law as much as for code.

## What is a cookie, in plain words? {#what-is-a-cookie-in-plain-words}

The web’s main language, [HTTP](https://ursy.com/wiki/http/), forgets each request as soon as it is answered. A cookie is the memory. MDN’s guide to [using HTTP cookies](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Cookies) describes it as a small piece of data a server sends to a browser, which the browser may store and send back. MDN lists 3 main uses:

- **Session management:**  keeping you signed in, holding a shopping basket.
- **Preferences:**  language, theme and other settings.
- **Tracking:**  recording and analysing what visitors do, often across visits.

## How does a cookie work? {#how-does-a-cookie-work}

The server sends a `Set-Cookie` header with its reply. The browser stores it. On the next request to the same site, the browser sends it back in a `Cookie` header. A simple pair looks like this:

```
Set-Cookie: basket=a3fW; Max-Age=2592000; Secure; HttpOnly; SameSite=Lax
Cookie: basket=a3fW
```

You can see these lines with our [HTTP header checker](https://ursy.com/http-header-checker/). The attributes after the value are the rules:

| Attribute | What it does |
| --- | --- |
| Expires / Max-Age | When the cookie is deleted. MDN says Max-Age wins if both are set. With neither, it is a session cookie. |
| Secure | Only sent over HTTPS, so it needs an [SSL certificate](https://ursy.com/wiki/ssl-certificate/). |
| HttpOnly | JavaScript cannot read it, which limits theft by injected scripts. |
| SameSite | Strict, Lax or None. Controls whether it is sent when another site links or loads in. None needs Secure. |
| Domain / Path | Which hosts and paths receive it. Setting Domain also shares it with each [subdomain](https://ursy.com/wiki/subdomain/). |

The formal rules are in [RFC 6265](https://www.rfc-editor.org/rfc/rfc6265) (April 2011). It asks browsers to support at least 4,096 bytes per cookie, 50 cookies per domain and 3,000 cookies in total. Those are minimums, not limits you should plan to reach.

## First-party or third-party? {#first-party-or-third-party}

A [first-party cookie](https://ursy.com/wiki/first-party-cookies/) is set by the site in the address bar. A third-party cookie is set by something else loaded into the page, such as an advert, a video or a chat widget. MDN notes that some browsers block third-party cookies by default. This is one reason analytics numbers drift lower over time, explained in [why analytics numbers are low](https://ursy.com/wiki/why-analytics-numbers-are-low/).

## What does UK law say? {#what-does-uk-law-say}

In the UK, cookies fall under [PECR](https://ursy.com/wiki/pecr/), with [UK GDPR](https://ursy.com/wiki/uk-gdpr/) on top when the cookie links to a person. The ICO’s guide to [cookies and similar technologies](https://ico.org.uk/for-organisations/direct-marketing-and-privacy-and-electronic-communications/guide-to-pecr/cookies-and-similar-technologies/) says you must tell people if you set cookies, explain clearly what they do and why, and get consent. It gives 2 exemptions: cookies used only to carry a communication, and cookies strictly necessary for a service the visitor asked for, such as a basket or a security cookie. The same rules cover similar methods of storing data on a device, not only cookies.

The law moved in 2025. The ICO’s summary of the [Data (Use and Access) Act 2025](https://ico.org.uk/about-the-ico/what-we-do/legislation-we-cover/data-use-and-access-act-2025/the-data-use-and-access-act-2025-what-does-it-mean-for-organisations/) says it allows some types of cookies without consent, such as those used for statistical purposes and to improve how a website works. The ICO’s own cookie guide says it is based on its previous guidance and that a revised version was under consultation, so read the ICO’s newest guidance before you drop a banner for analytics. Our page on the [cookie banner](https://ursy.com/wiki/cookie-banner/) covers the design side.

## Why does it matter for search? {#why-does-it-matter-for-search}

[Googlebot](https://ursy.com/wiki/googlebot/) and other crawlers do not sign in or keep your basket. Any content that only appears once a cookie is set may be invisible to a [search crawler](https://ursy.com/wiki/search-crawler/). A consent wall that hides the whole page until a click can do the same. Keep the main text in the [HTML](https://ursy.com/wiki/html/) and let the banner sit on top of it. Cookies used to vary content by visitor can also create near-copies of a page, which is a [duplicate content](https://ursy.com/wiki/duplicate-content/) risk if each version gets its own address.

## Why does it matter for AI answers? {#why-does-it-matter-for-ai-answers}

[AI crawlers](https://ursy.com/wiki/ai-crawler/) and [live fetchers](https://ursy.com/wiki/live-fetcher/), such as [GPTBot](https://ursy.com/wiki/gptbot/) or [ChatGPT-User](https://ursy.com/wiki/chatgpt-user/), fetch a page much like a first-time visitor with no cookies. If your prices, stock or opening hours depend on a cookie, the AI reads the default version. Make sure the default answers the question. Our [AI readiness checker](https://ursy.com/ai-readiness-checker/) gives a quick view of how ready a page is for AI readers.

## What are the common mistakes? {#what-are-the-common-mistakes}

- **Setting analytics or advert cookies before consent.**  Many tag setups fire on page load. [Consent Mode v2](https://ursy.com/wiki/consent-mode-v2/) and a careful [Google Tag Manager](https://ursy.com/wiki/google-tag-manager/) setup help, but test it.
- **Calling every cookie “essential”.**  The ICO’s test is strict: essential to the service the visitor asked for, not merely helpful to you.
- **Leaving off Secure and HttpOnly**  on sign-in cookies. Our [security headers checker](https://ursy.com/security-headers-checker/) flags weak settings.
- **Huge cookies.**  MDN notes cookies go with every request and can slow pages. Store bulky data with Web Storage instead.
- **A cookie policy that does not match reality.**  List what is really set, and check it again after each new plugin.

## A worked example {#a-worked-example}

A visitor lands on a small shop with no cookies. The reply sets one cookie, `session=7Qx`, marked Secure, HttpOnly and SameSite=Lax. She adds a lamp to her basket, and every page she opens sends `session=7Qx` back, so the basket stays full. This cookie is strictly necessary, so no consent is needed. The same page also loads an advert pixel that would set a third-party cookie for tracking. That one must wait until she agrees on the banner. If she says no, the shop still works and the pixel never fires.

## How do I check my cookies? {#how-do-i-check-my-cookies}

1. Open your site in a private window, then open the browser’s developer tools and look at the storage panel before you click anything.
2. Note each cookie, who set it and how long it lasts.
3. Run our [cookie checker](https://ursy.com/cookie-checker/) and [tracking checker](https://ursy.com/tracking-checker/) for a list in plain words.
4. Check the raw `Set-Cookie` lines with the [HTTP header checker](https://ursy.com/http-header-checker/).
5. If you want fewer banners, read about [cookieless analytics](https://ursy.com/wiki/cookieless-analytics/).

## Questions {#questions}

### Is a cookie a virus or a program? {#is-a-cookie-a-virus-or-a-program}

No. It is a short piece of text. It cannot run code by itself.

### Do I need a banner if I only use necessary cookies? {#do-i-need-a-banner-if-i-only-use-necessary-cookies}

Under the ICO guidance, strictly necessary cookies do not need consent, but you still need to tell people about them, usually in a privacy or cookie notice.

### What is the difference between a cookie and local storage? {#what-is-the-difference-between-a-cookie-and-local-storage}

MDN explains that Web Storage stays in the browser and is never sent to the server by itself, while cookies go with every request. PECR still applies to both when they store data on the device.

## Related words {#related-words}

- [First-party cookies](https://ursy.com/wiki/first-party-cookies/)
- [Cookie banner](https://ursy.com/wiki/cookie-banner/)
- [PECR](https://ursy.com/wiki/pecr/)
- [Consent Mode v2 for UK websites](https://ursy.com/wiki/consent-mode-v2-for-uk-websites/)
- [Session](https://ursy.com/wiki/session/)

## Sources {#sources}

- [MDN Web Docs: Using HTTP cookies](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Cookies), checked 24 November 2026
- [IETF RFC 6265: HTTP State Management Mechanism (April 2011)](https://www.rfc-editor.org/rfc/rfc6265), checked 24 November 2026
- [ICO: Cookies and similar technologies](https://ico.org.uk/for-organisations/direct-marketing-and-privacy-and-electronic-communications/guide-to-pecr/cookies-and-similar-technologies/), checked 24 November 2026
- [ICO: The Data (Use and Access) Act 2025, what does it mean for organisations?](https://ico.org.uk/about-the-ico/what-we-do/legislation-we-cover/data-use-and-access-act-2025/the-data-use-and-access-act-2025-what-does-it-mean-for-organisations/), checked 24 November 2026

*Updated 24 November 2026 by URSY.com.*
