What Is a Cookie? How Browser Cookies Work, Types and Privacy
A cookie, also called a browser cookie, HTTP cookie or web cookie, is a small text file that a website asks your browser to store on your device. It holds a short string of data — such as a session ID, a language preference or a sign-in token — so the web server can recognise your browser when you return or move to another page. A cookie is not a program, it cannot run code, and it does not contain your whole browsing history.
Without cookies, the web would forget you constantly. Your shopping basket would empty at each click, and you would have to log in again on every page. Cookies are the quiet memory that makes everyday browsing feel continuous.
Think of a Cookie Like a Coat-Check Ticket
Imagine you leave your coat at a theatre cloakroom. The attendant hands you a small numbered ticket. The ticket is not your coat, and it tells nobody your name or address. It simply proves, when you come back, which coat belongs to you.
A browser cookie works in almost the same way. The number on the ticket is like the random ID inside the cookie file. The cloakroom rail is like the information the website keeps on its own server — your basket, account and settings. Anyone holding the right ticket can claim the right coat, which is also why cookies need care: if someone steals your ticket, they may be able to step into your session.
A ticket from one theatre does not work at another, just as a cookie set by one domain cannot normally be read by a different domain.
How Cookies Work, Step by Step
Every cookie follows the same round trip between your browser (identified by its user agent) and a web server, using HTTP headers:
- You visit a website. Your browser sends a request to the web server, along with its user agent and any cookies already stored for that site.
- The server replies with a Set-Cookie header. Alongside the page, the response can include a Set-Cookie instruction telling the browser to save a name, a value and an expiry date.
- Your browser stores the file. The cookie is saved with the domain that set it, so it is only sent back to that domain later.
- You click another page or return tomorrow. Your browser attaches the cookie to its request in a Cookie header, so the server recognises the session without asking you to log in again.
- The cookie expires or is deleted. At its expiry date, or when you clear it, the browser removes it and the site treats your next visit as a fresh start.

Cookies are often confused with browser cache and local storage. The browser cache stores copies of images and pages so they load faster next time. Local storage lets a website keep larger data inside the browser for web apps. A cookie is much smaller — around 4KB at most — and, unlike the other two, it is sent to the server with every request, which is why it is used for identity and sessions.
The Main Types of Cookies
Cookies differ by lifespan and by origin. A session cookie disappears when you close the browser, while a persistent cookie stays until its expiry date. Two unusual kinds are worth knowing too: supercookies are tracking identifiers placed in less obvious locations, sometimes by internet providers, and are much harder to find and delete; zombie cookies are designed to recreate themselves after deletion, using backup copies stored elsewhere in the browser. Both are considered invasive because they defeat the control users expect to have.
| Type | Where it comes from | How long it lasts | Main job |
|---|---|---|---|
| Session cookie | The website you are visiting | Until you close the browser | Keeps you logged in and remembers your basket while you browse |
| Persistent cookie | The website you are visiting | Days, months or up to its set expiry date | Remembers preferences, language and return visits |
| First-party cookie | The domain in your address bar | Session length or a set expiry date | Sign-in, settings and basic site analytics |
| Third-party cookie | A different domain, such as an advertiser or embedded service | Usually a set expiry date, often months | Cross-site tracking, advertising and embedded content |
Most cookies on your device are ordinary and useful. Session and first-party kinds keep sites working, persistent cookies save you resetting preferences, and it is mainly the third-party tracking cookie — plus rare supercookies and zombie cookies — that raises the privacy questions covered below.
First-Party vs Third-Party Cookies
The difference is who sets the cookie. A first-party cookie is created by the website you deliberately visited. If you open an online shop, sign in and choose English as your language, that shop’s own cookies remember all three things. Block them and the site quickly becomes painful to use.
A third-party cookie is set by someone else whose code is loaded inside the page — an advertising network, a social media button, a video embed or an analytics provider. Because the same network appears on thousands of sites, its tracking cookie can follow your browser from a news article to a travel page to a shop, building a profile of your interests for targeted advertising.
That is why modern browsers treat the two kinds differently: first-party cookies are generally allowed, while third-party cookies are increasingly blocked by default or limited. The wider web runs on connected services in a similar way — technologies such as those explained in our guide to how RSS feeds work also let one site’s content appear inside another, which is why it matters who is placing data on your device.
Are Cookies Safe? Privacy, Tracking and Consent
A cookie itself is not a virus and cannot install anything. The real risks are privacy and session security. A tracking cookie can reveal a detailed picture of your habits over time. And if an attacker steals an active session cookie — usually through malware or an unsafe network — they may be able to impersonate you without knowing your password. An up-to-date browser, avoiding suspicious downloads and logging out on shared devices all reduce that risk.
Permission matters here too. In the same way a browser asks before a site can use your location — the technology our article on what a geofence is explains from the other side — privacy law increasingly requires sites to ask before they track you. Under the GDPR and the ePrivacy rules in Europe, non-essential cookies, especially advertising and analytics cookies, generally need your cookie consent first. That is why you see consent banners asking you to accept, reject or customise cookies.
Some sites go further with cookie walls, which block access until you accept tracking. Regulators have criticised designs that make “reject” hard to find, so a good banner gives an equally easy choice. Reject non-essential cookies and the site should still work, with less personal ads. Incognito mode deletes cookies when you close the private window, though it does not hide your activity from your provider or employer.

How to View, Clear and Block Cookies
In Google Chrome, open Settings, then “Privacy and security”. Choose “Third-party cookies” to control whether sites can use them, and use the lock icon next to any web address to see which cookies a particular site has stored. To remove them, select “Clear browsing data”, tick “Cookies and other site data”, choose a time range and confirm. Clearing cookies signs you out of most websites.
The steps are similar in other browsers: open privacy or site settings, find cookies or site data, and you can view, delete or block them. Blocking everything breaks sign-ins and baskets, so blocking third-party cookies only is the sensible middle ground. Your connection makes no difference: whether your phone uses Wi-Fi or the mobile technology in our explainer on what 5G is and how it works, cookies work the same way.
Frequently Asked Questions
Is a cookie the same as browser cache?
No. A cookie is a tiny text file holding an ID or preference, sent to the web server with each request. The browser cache stores copies of page files, such as images, to make repeat visits faster, and it is never sent to the server.
Can cookies steal my passwords?
Cookies do not store your actual password in normal use, but a stolen session cookie can let an attacker use a logged-in session. Keep your browser updated, avoid malware and log out on shared computers.
Should I accept all cookies?
You do not have to. Essential cookies are needed for a site to work, but you can reject optional tracking and advertising cookies in the cookie consent banner. The site should still function, with less personalised advertising.
Do cookies work in incognito mode?
Yes, but only temporarily. In incognito mode the browser creates a short-lived session and deletes the cookies when you close the private window, so sites cannot recognise you from a previous visit.





