Explainer
What are cookies on websites?
How do cookies work?
On its own, the web has no memory: each page request looks like it comes from a stranger. Cookies fix that. A site sends an instruction with the page saying, in effect, "store this name and value", and your browser attaches it to every later request to that site.
A cookie is usually a short label and a random-looking string, such as session=8f3a91c2: a reference number the site matches against its own records. That is how it keeps you logged in without storing your password.
Each cookie also carries rules: which site it belongs to, whether it may travel only over secure (HTTPS) connections, and when it expires. Browsers limit cookies to roughly 4 KB each, enough for identifiers and small settings.
What is the difference between first-party and third-party cookies?
A first-party cookie is set by the site shown in your address bar, such as a news site remembering your font size. These power most everyday features and are rarely blocked.
A third-party cookie is set by a different domain loaded inside the page: an ad, a share button, an embedded video or an invisible tracking pixel. Because one ad company may be embedded on thousands of sites, it can recognise your browser on a recipe site, a shoe shop and a travel blog, and link those visits into one profile.
First-party cookies can track you too, within one site or when a site shares data with partners, but cross-site tracking has mostly relied on third-party cookies.
What are session cookies and persistent cookies?
A session cookie has no expiry date and is deleted when the session ends, usually when you close the browser. Browsers that restore your previous tabs can keep them alive longer.
A persistent cookie has an expiry date, from minutes to many months. "Remember me" logins, language choices and advertising identifiers are usually persistent. Chrome caps cookie lifetimes at 400 days, so a cookie claiming to last ten years will not.
What are cookies used for?
Most cookies fall into four groups. Strictly necessary cookies make a service work: logins, baskets and security checks. Preference cookies remember choices like language or dark mode. Analytics cookies count visits. Advertising cookies choose ads, limit repeats and measure whether an ad led to a purchase.
Your consent choice is itself stored in a cookie, which is why clearing cookies brings the banners back.
How do tracking cookies and ad tech follow you?
When a page loads an ad, your browser sends the ad company's cookie along with the request, telling it this browser visited this page. Across thousands of sites, it can infer interests such as running or mortgages and sell ads targeted at them.
In real-time bidding, advertisers bid for an ad slot in the instant a page loads, using what is known about the page and you. Cookie syncing lets ad companies match their identifiers for the same browser.
Blocking third-party cookies does not end tracking. Companies also use logins, IP addresses and browser fingerprinting (combining details like screen size and fonts into a near-unique signature). The UK's Information Commissioner's Office (ICO) applies the same consent rules to these technologies.
Why do websites show cookie consent banners?
In the European Union, the ePrivacy Directive says a site may store or read information on your device only if you are given clear information and agree, unless it is strictly necessary for a service you asked for. The GDPR (General Data Protection Regulation) sets the standard for valid consent: freely given, specific, informed and an unambiguous positive action. The UK has equivalent rules in its Privacy and Electronic Communications Regulations (PECR) and the UK GDPR.
Hence the banners. Necessary cookies, like a basket, do not need consent; analytics and advertising cookies generally do. The ICO says continuing to browse is not consent, pre-ticked boxes are invalid, and rejecting should be as easy as accepting.
In the United States, laws such as California's mainly give you a right to opt out of the "sale or sharing" of your data rather than requiring consent first, and covered businesses must honour browser opt-out signals such as Global Privacy Control. The EU has been negotiating changes to its cookie rules in 2026. This is the general picture, not legal advice.
How do you view, clear or block cookies?
Every major browser lets you view and delete cookies in its privacy settings: everything, a time range, or one site. The icon left of the address bar often shows a site's cookies. Clearing cookies signs you out and resets preferences, so clear selectively.
To limit tracking without breaking logins, block third-party cookies only. Safari blocks them by default, and Firefox keeps each site's cookies in a separate jar by default. In Chrome, the option is under Settings, Privacy and security; Incognito windows block them by default.
Private windows delete their cookies when closed but do not hide activity from sites or your internet provider. A VPN hides your IP address but does not remove cookies.
Is Chrome getting rid of third-party cookies?
No. Google spent years planning to phase out third-party cookies in Chrome through its Privacy Sandbox project, and in January 2024 it restricted them for 1% of Chrome users as a test. On 22 July 2024 it dropped the plan to remove them, proposing instead a prompt letting people choose. On 22 April 2025 Google said it would not launch that standalone prompt either, and would keep the existing choice in Chrome's settings, with third-party cookies still allowed by default.
On 17 October 2025 Google said it would retire most Privacy Sandbox technologies, including the Topics API, Protected Audience and Attribution Reporting, citing low adoption. It kept CHIPS (partitioned cookies that cannot follow you across sites) and FedCM (for "Sign in with" buttons).
So, as of late 2026, Chrome allows third-party cookies unless you turn them off, while Safari and Firefox restrict them by default.
Common types of website cookies and their privacy impact
| Cookie type | Set by | Typical use | Privacy impact |
|---|---|---|---|
| Session (login) cookie | The site you are on | Keeps you signed in while you browse | Low; needed for the service, but valuable to attackers if stolen |
| Shopping basket cookie | The site you are on | Remembers items before checkout | Low; usually counts as strictly necessary |
| Preference cookie | The site you are on | Language, region, dark mode, font size | Low; reveals little beyond your settings |
| Consent cookie | The site or its consent tool | Records what you chose in the cookie banner | Low; needed so the banner does not reappear |
| First-party analytics cookie | The site, often via an analytics tool | Counts visits and popular pages | Medium; activity is measured, usually within one site |
| Third-party advertising cookie | An ad company embedded in the page | Targets ads and measures conversions across sites | High; can build a profile of browsing across many sites |
| Social media cookie | A social network via buttons or embeds | Share buttons, embedded posts, ad measurement | High; can link visits to a real-name account |
| Partitioned (CHIPS) cookie | An embedded service, kept per top-level site | Chat widgets, embedded maps or payments | Lower; cannot be read across different sites |
Examples
- You close your bank's tab and reopen it ten minutes later; a session cookie keeps you signed in.
- A jacket stays in your basket overnight because of a persistent first-party cookie.
- Hiking boots you viewed in one shop appear in ads on a news site, because an ad company's third-party cookie recognised your browser on both.
- You click "Reject all"; the site stores a consent cookie to remember that choice and skips advertising cookies.
Common questions
Can cookies contain viruses or malware?
No. A cookie is plain text; it cannot run code or install anything. The real risks are tracking and account security: if malware already on your device steals a login cookie, an attacker may be able to use your session without your password.
Should I accept or reject cookies?
Rejecting non-essential cookies is safe and the site should still work, because strictly necessary cookies do not need consent. Accepting mainly means more analytics and ad tracking. Some people accept on sites they want to support. You can usually change your choice later through a link in the site's footer.
Do cookies store my passwords or card details?
Reputable sites do not. They store a random session identifier that points to your account on their server. Saved passwords live in your browser's or password manager's encrypted store, separate from cookies, so clearing cookies signs you out without deleting them.
Does clearing cookies stop all tracking?
No. New cookies are set as soon as you browse again, and logins, IP addresses and fingerprinting still work. Clearing helps most combined with blocking third-party cookies and a privacy-focused browser or extension.
Why do I see cookie banners on every website?
Many sites use analytics or advertising tools that need consent under European and UK law, and global sites often show one banner to everyone. Your answer is stored in a cookie, so clearing cookies or using private browsing brings the banner back.
Sources and further reading
- Using HTTP cookies — MDN Web Docs
- Third-party cookies — MDN Web Docs
- How do we comply with the PECR rules? (storage and access technologies guidance) — Information Commissioner's Office (UK)
- Directive 2002/58/EC (ePrivacy Directive) — EUR-Lex, European Union
- Next steps for Privacy Sandbox and tracking protections in Chrome — Google Privacy Sandbox
- Update on plans for Privacy Sandbox technologies — Google Privacy Sandbox
Glossary terms
Keep reading
- Cookies vs local storage
Cookies are small values (about 4 KB each) that the browser sends to the server automatically with matching requests, and they can be hidden from JavaScript with HttpOnly. Local storage holds around 5 MiB of strings per origin, is never sent automatically, and is always readable by any script on the page. Use cookies for sessions, localStorage for client-only state.
- What is a VPN?
A VPN (virtual private network) is an encrypted tunnel between your device and a server run by someone else. Your local network and internet provider see only scrambled traffic going to that server, and websites see the server's IP address instead of yours. It does not make you anonymous: the VPN provider can now see what your ISP used to.
- What are app permissions?
App permissions are the device or browser gates that control what an app can access—camera, microphone, location, photos, contacts, notifications, and more. Good hygiene means granting only what the feature needs, when it needs it.
- What is a password manager?
A password manager is an app that creates, stores and fills in your passwords for you. Your logins are kept in an encrypted vault that you unlock with one master password, a device PIN or your fingerprint. It lets you use a different strong password on every site without having to remember any of them.
- What is phishing?
Phishing is a scam in which someone pretends to be a trusted person or organisation to trick you into revealing passwords or payment details, clicking a harmful link, or sending money. It arrives by email, text, phone call, social media or QR code, and usually relies on urgency or fear to make you act fast.