How a cookie works
When you visit a site, the server can include a line in its reply asking your browser to store a cookie: a name and a value. On later requests to that site, your browser sends the cookie back. HTTP, the language of the web, does not remember anything between requests on its own, so cookies are how sites remember state — for example, keeping you signed in.1
Cookies are small. Browsers usually allow about 4 KB per cookie and cap how many each site can store, generally in the hundreds.1 The UK's data protection regulator, the ICO, describes them as small files stored on your device, and the same rules also cover similar techniques such as device fingerprinting.2
What sites use them for
MDN groups the main uses into three:
- Sessions: sign-ins, shopping baskets, game scores.1
- Personalisation: your settings and preferences.1
- Tracking: recording and analysing what you do.1
First-party vs third-party
| First-party | Third-party | |
|---|---|---|
| Set by | The site in your address bar | Another company whose content is embedded (ads, widgets) |
| Typical use | Sign-in, basket, settings | Cross-site advertising and measurement |
| If you block them | Sites may log you out or forget settings | Some embedded widgets may stop working |
A third-party cookie comes from content embedded in the page you are on. Because the same company can be embedded on many sites, it can recognise you as you move between them. Some browsers now block third-party cookies by default, and blocking them can stop some third-party widgets working.1
How long cookies last
- Session cookies have no expiry date and are deleted when the browser session ends — although a browser's "restore previous session" feature can keep them alive much longer.1
- Permanent cookies last until a set date (Expires) or for a set period (Max-Age).1
Sites can also add safety flags. Secure means the cookie is only sent over encrypted HTTPS connections, HttpOnly hides it from scripts running in the page, and SameSite controls whether it is sent when another site links or embeds content.1

Cookie banners and your rights
In the UK, sites must tell you clearly what cookies they use and, for any cookie that is not strictly necessary, get your consent before setting it.2 The ICO says "strictly necessary" is judged from your point of view as the user, not from the site's business model; examples include sign-in and security.3 The rules apply to any information stored on or read from your device, not just personal data.3
If you think a site is ignoring the rules, the ICO asks people to report cookie concerns through its complaints page. It publishes figures on the complaints it receives rather than replying to each one individually.2
How to delete or block cookies

Chrome on a computer
- Select More (the three dots, top right), then Delete browsing data.4
- Choose a time range, such as Last hour or All time.4
- Tick Cookies and other site data, then select Delete data.4
To block third-party cookies, go to Settings > Privacy and security > Third-party cookies and choose Block third-party cookies. You can still allow particular sites under "Sites allowed to use third-party cookies".4
Chrome on Android
Go to More > Settings > Privacy and security > Delete browsing data, tick Cookies and site data and tap Delete data. Third-party cookie options are under More > Settings > Site settings > Third-party cookies.4
Chrome on iPhone and iPad
Go to More > Settings > Privacy and security > Delete browsing data, tick Cookies, site data, then tap Delete browsing data.4
Firefox
Firefox's Total Cookie Protection is on by default. It gives every website its own separate "cookie jar", so third parties can't use cookies to follow you from site to site.5 If a site misbehaves, you can turn off Enhanced Tracking Protection for that site only, using the shield icon in the address bar.5
Safari on a Mac
Choose Safari > Settings, click Privacy, then Manage Website Data. Select sites and click Remove, or click Remove All.6 In the same Privacy pane, Prevent cross-site tracking deletes cookies and data from trackers unless you visit them directly as a site.7
Cookies and private browsing
In Chrome's Incognito mode, cookies work during the session and are removed when you close all Incognito windows. Third-party cookies are blocked by default in Incognito.8 It does not make you invisible to the websites you visit, your employer or school, or your internet provider.8 See What Does Private Browsing Actually Hide?
Common questions
Should I accept or reject cookies?
That is your choice. Sites need your consent for cookies that are not strictly necessary, such as most advertising cookies, but they can use strictly necessary ones — like the cookie that keeps you signed in — without asking.2,3
Do browsers block third-party cookies?
It depends on the browser. Firefox isolates them by default with Total Cookie Protection.5 Chrome blocks them by default in Incognito and lets you block them in normal windows in its settings.8,4 Safari offers a "Prevent cross-site tracking" setting.7
Does clearing cookies sign me out?
Yes. Deleting cookies can sign you out of sites and remove saved preferences.4 Apple gives the same warning for Safari.6
Can websites see my cookies from other sites?
No. A cookie is only sent back to the site that set it (and, if the site chooses, its subdomains).1 Third-party cookies work across sites because the same company is embedded on many of them, so it sees its own cookie each time.1
Are cookies a virus?
No. A cookie is a small piece of data, usually no more than about 4 KB, that your browser stores and sends back to a website.1
Does "Do Not Track" stop cookies?
Not reliably. Do Not Track is only a preference you send, and websites don't have to honour it.2
Related guides
- What Does Private Browsing Actually Hide?: cookies in private windows.
- 10 Tips to Make Your Web Browser Faster and Safer: tidy up your browser.
- What Does "Not Secure" Mean in Your Browser?: why HTTPS matters.
- 12 Online Shopping Safety Tips: shop safely online.
- How to Clear Cache and Cookies: step by step for Chrome, Safari, Firefox and Edge.
