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? #
The web’s main language, HTTP, forgets each request as soon as it is answered. A cookie is the memory. MDN’s guide to using HTTP 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? #
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. 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. |
| 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. |
The formal rules are in RFC 6265 (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? #
A first-party cookie 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.
What does UK law say? #
In the UK, cookies fall under PECR, with UK GDPR on top when the cookie links to a person. The ICO’s guide to 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 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 covers the design side.
Why does it matter for search? #
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. A consent wall that hides the whole page until a click can do the same. Keep the main text in the 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 risk if each version gets its own address.
Why does it matter for AI answers? #
AI crawlers and live fetchers, such as GPTBot or 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 gives a quick view of how ready a page is for AI readers.
What are the common mistakes? #
- Setting analytics or advert cookies before consent. Many tag setups fire on page load. Consent Mode v2 and a careful 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 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 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? #
- Open your site in a private window, then open the browser’s developer tools and look at the storage panel before you click anything.
- Note each cookie, who set it and how long it lasts.
- Run our cookie checker and tracking checker for a list in plain words.
- Check the raw
Set-Cookielines with the HTTP header checker. - If you want fewer banners, read about cookieless analytics.
Questions #
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? #
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? #
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 #
Sources #
- MDN Web Docs: Using HTTP cookies, checked 24 November 2026
- IETF RFC 6265: HTTP State Management Mechanism (April 2011), checked 24 November 2026
- ICO: Cookies and similar technologies, checked 24 November 2026
- ICO: The Data (Use and Access) Act 2025, what does it mean for organisations?, checked 24 November 2026
Updated 24 November 2026 by URSY.com.
Cite this page: Cookie. URSY. Updated 26 November 2026. https://ursy.com/wiki/cookie/ · Section links
Tools for this
- LiveCookie Checkerwhat a page sets before consentRun the check →
- LiveUK Shop Compliance Checkerunit prices, returns, company details, delivery and cookie bannerRun the check →
- LiveAI Readiness Checkeris your site ready for ChatGPT, Gemini, Claude? Score + fixesRun the check →
- LiveAI Bot Checkerwhich AI bots your robots.txt lets inRun the check →
- LiveRobots.txt Checker + Generatortest any address against your rules, or write new onesRun the check →
- LiveSchema Markup CheckerRun the check →
- ProCookie-free analyticsVisits, pages, sources, without cookiesIn URSY Pro →