What Is a Cookie on a Website?

Cookies keep you signed in and remember your basket. They can also follow you between sites. Here’s the difference.

Short answer

A cookie is a small piece of data a website asks your browser to store. Your browser sends it back to that site on later visits, which lets the site remember things — that you’re signed in, what’s in your basket, your language. The web itself doesn’t remember you between pages, so cookies fill that gap. Cookies set by other companies embedded in a page — third-party cookies — can be used to recognise you across different sites.

In this article 9 sections
  1. How a cookie works
  2. What sites use them for
  3. First-party vs third-party
  4. How long cookies last
  5. Cookie banners and your rights
  6. How to delete or block cookies
  7. Cookies and private browsing
  8. Common questions
  9. Related guides
Diagram of two different websites that both load an advertising banner from the same third-party server, lotofbanners.com.
Diagram: Tizio / Wikimedia Commons, CC BY-SA 3.0

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

Two kinds of cookie
First-partyThird-party
Set byThe site in your address barAnother company whose content is embedded (ads, widgets)
Typical useSign-in, basket, settingsCross-site advertising and measurement
If you block themSites may log you out or forget settingsSome 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

Chrome settings showing one stored cookie in detail: its name, blurred content, domain, path, “Secure connections only”, “HttpOnly” and an expiry of when the browsing session ends.
Chrome’s site-data settings show what a single cookie holds, including its Secure and HttpOnly flags and when it expires — this one is a session cookie. Screenshot: Fuzheado / Wikimedia Commons, CC0

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

The cookie settings window of an older version of the Firefox web browser, listing cookies stored by websites
A browser's cookie manager lists the cookies each website has stored on your device — this one is from an older version of Firefox. Screenshot: Mozilla Foundation / Wikimedia Commons, CC BY-SA 4.0

Chrome on a computer

  1. Select More (the three dots, top right), then Delete browsing data.4
  2. Choose a time range, such as Last hour or All time.4
  3. 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

Sources and further reading

  1. Using HTTP cookies — MDN Web Docs (Mozilla)2026-11-17
  2. Cookies — Information Commissioner's Office (UK)2026-04-30
  3. Fact vs fiction: ICO debunks myths on storage and access technologies — Information Commissioner's Office (UK)2025-09-11
  4. Delete, allow and manage cookies in Chrome — Google Chrome Help
  5. Introducing Total Cookie Protection in Standard Mode — Mozilla Support2025-05-20
  6. Clear your cache and cookies in Safari on Mac — Apple Support
  7. Prevent cross-site tracking in Safari on Mac — Apple Support
  8. Browse in Incognito mode — Google Chrome Help

Was this article helpful?

Comments

No comments yet. Questions and tips from readers are welcome.