Skip to main content
Season 3 ends in 16 d 22:15:50 $2,000 10,000 pts = 1 month Premium
Technology

What Are Cookies? How Websites Remember and Track You

Published 20 min read
Open the post and read it to claim 30 points
Glowing round data tokens flowing from a laptop screen toward a lit server tower on a dark desk

Sign in and earn +30 points by reading this

Read to the end, wait a few seconds, then tap the claim button below.

In short

Cookies are small pieces of data that a website asks your browser to store and send back on later visits, so the site can remember you [1][3]. They keep you signed in, hold a shopping basket and save settings, but third-party cookies can also follow you across sites to build an advertising profile [1][2].

Key takeaways

  1. A cookie is a small piece of text data, usually a name and a value, that a server sends to your browser and the browser returns with later requests [1][3].
  2. Cookies exist because the web's basic protocol, HTTP, does not remember anything between page loads on its own [1][3].
  3. The three main uses are session management (sign-ins, baskets), personalisation (language, theme) and tracking [1].
  4. First-party cookies come from the site you are visiting; third-party cookies come from other domains embedded in the page, such as ad networks [2].
  5. Cookies are data, not programs: they cannot run code or infect your device, but a stolen sign-in cookie can let someone into your account [1][5].
  6. In the EU and UK, sites must ask for your consent before setting cookies that are not strictly necessary, and refusing must be as easy as accepting [6][7][8].
  7. You can view, block and delete cookies in every major browser; Firefox and Safari already limit cross-site cookies by default [2][5].
On this page 14 sections
  1. What are cookies on a website?
  2. How do cookies work?
  3. What are cookies used for?
  4. What is the difference between first-party and third-party cookies?
  5. How do cookies track you across websites?
  6. Are cookies dangerous?
  7. Why do websites ask you to accept cookies?
  8. Should you accept or reject cookies?
  9. How do you view, block and delete cookies?
  10. What is replacing third-party cookies?
  11. Common mistakes
  12. Frequently asked questions
  13. Glossary
  14. Sources

What are cookies on a website?

A cookie is a small piece of data that a website's server sends to your web browser, which the browser stores and sends back to the same site with later requests [1].

Mozilla's developer documentation, MDN, describes a cookie as a small piece of data a server sends to a user's web browser, which the browser may store, change and send back to the same server later [1]. The UK data protection regulator, the Information Commissioner's Office (ICO), puts it in plainer words: a small file of letters and numbers that is downloaded on to your computer when you visit a website [5].

Why do websites need them? The web's basic protocol, HTTP, is stateless: each request for a page is handled on its own, with no memory of the previous one [1][3]. Without some extra mechanism, a shop would forget what is in your basket every time you clicked a new page, and you would have to sign in again on every screen. Cookies are that mechanism. The official internet standard for them, RFC 6265 from the Internet Engineering Task Force (IETF), describes cookies as a way to let servers maintain a stateful session over the mostly stateless HTTP protocol [3].

Cookies are old. They began as a proposal from Netscape in the early days of the web, and the first IETF standard for them, RFC 2109, was published in February 1997 [4]. The current standard, RFC 6265, dates from April 2011 [3]. That same standard admits that cookies have many historical infelicities that degrade their security and privacy, yet they remain widely used [3].

The name has nothing to do with food in your computer. A cookie is text data, often just a name and a value such as a random ID, stored by your browser in its own files [1][3].

How do cookies work?

A server sends a cookie in a Set-Cookie header with its response; your browser stores it and attaches it in a Cookie header to every later request to that site until it expires or is deleted [1][3].

The exchange can be followed in four steps [1]:

  1. You visit a site. Your browser asks the server for a page.
  2. The server sets a cookie. Along with the page it sends one or more Set-Cookie headers, each containing a name and a value, for example an ID for your session.
  3. The browser stores it. It keeps the cookie together with rules about where and how long it applies.
  4. The browser sends it back. On every later request to that site, the browser includes the stored cookies in a Cookie header, so the server can recognise the same browser.

A typical sign-in works exactly this way: after you enter the right password, the server responds with a cookie containing a session ID; when you open another page on the same site, the browser sends the cookie back, the server checks the ID and shows you the signed-in version [1].

Cookies can also be created by scripts running in the page, through a JavaScript feature called document.cookie [1].

Each cookie carries attributes that control its behaviour [1]:

  • Expires or Max-Age decide how long it lasts. Without them it is a session cookie, deleted when the browser session ends; with them it is a persistent cookie that survives restarts until the date passes [1].
  • Domain and Path decide which addresses receive it [1].
  • Secure means it is only sent over encrypted HTTPS connections [1].
  • HttpOnly hides it from scripts in the page, which helps protect sign-in cookies from cross-site scripting attacks [1].
  • SameSite controls whether it is sent with requests that come from other sites, with the values Strict, Lax or None [1].

Cookies are deliberately small. The standard asks browsers to support at least 4096 bytes per cookie, at least 50 cookies per domain and at least 3000 cookies in total [3]. For storing larger amounts of data, websites are now advised to use other browser storage features that are never sent to the server automatically [1].

A server and a blank browser window linked by a gold arc and a blue arc, each carrying a small round token
The server sends a cookie with its response, and the browser sends it back with every later request to the same site.

What are cookies used for?

Websites use cookies for three main jobs: keeping a session going, remembering your preferences and tracking what you do [1].

  • Session management. Sign-in status, shopping cart contents, game scores or anything else a server needs to remember while you use the site [1]. The ICO's examples are remembering your preferences, recording what you have put in your shopping basket and counting the number of people looking at a website [5].
  • Personalisation. Settings such as your display language or a light or dark theme [1].
  • Tracking. Recording and analysing how people use a site, and, with third-party cookies, how they move across many sites [1][2].

Cookies also have security uses. Settings such as SameSite also give some protection against forged requests sent from other websites [1]. The EU treats some of these as strictly necessary: cookies that keep a shopping basket working, authenticate a signed-in user or spread traffic across several servers do not need consent [7].

Many of the cookies on a typical page, however, are not needed to deliver the service you asked for. They are there for analytics, advertising and social media features, which is why the law treats them differently, as explained further below [7].

What is the difference between first-party and third-party cookies?

A first-party cookie comes from the site shown in your address bar; a third-party cookie comes from a different domain whose content is embedded in the page, such as an ad, a video player or a social media button [2].

MDN defines it by domain and scheme: if a cookie's domain matches the page you are looking at, it is a first-party cookie; if it belongs to a different site, it is a third-party, or cross-site, cookie [2]. Third-party cookies are set in two common situations: when you click a link from one site to another, and when a page embeds images, iframes or scripts from other sites, which can trigger further requests that set more cookies [2].

Third-party cookies have legitimate uses, such as a single sign-in widget shared across a company's related sites, sharing preferences between sites or counting ad impressions [2]. The problem is that the same technique can be used to follow people across the web without their knowledge, and the legitimate and invasive uses are technically indistinguishable [2].

The IETF standard itself calls third-party cookies particularly worrisome: an advertising network embedded on two different sites can track the user between them, even if the user never visits the advertiser directly [3].

How do cookies track you across websites?

When the same advertising or analytics company is embedded on many sites, its cookie is sent back to it from each one, so it can link your visits into a profile of your browsing and interests [2][3].

Imagine an ad network whose code appears on a news site, a recipe blog and an online shop. The first time your browser loads one of its ads, the network sets a cookie with a unique ID. Every time another site loads content from the same network, your browser sends that ID back, along with information about which page you are on [3]. Put together, these visits form a record of where you have been. MDN gives the classic example: you search for a product on one site and are then chased around the web by adverts for similar products [1].

MDN warns that third-party servers can combine information from cookies set across different sites to build a detailed profile of a user's browsing history, interests, habits and personal information, which can be used for targeted ads, manipulation or even fraud [2]. In such cases third-party cookies are referred to as tracking cookies [2].

Cookies are not the only tracking tool. The UK's cookie rules also cover similar technologies for storing or accessing information on a device, including so-called Flash cookies and device fingerprinting, which identifies a browser from its unique combination of settings rather than from a stored file [5][6]. Deleting cookies therefore reduces tracking but does not end it.

Similar questions about what services do with your data apply well beyond cookies; our guide "Is ChatGPT Safe for Privacy? What Happens to Your Data" looks at one example in detail.

Five floating blank web page panels, each with a small gold square, linked by glowing threads to one central sphere
A third party embedded on many sites receives its cookie back from each one and can link the visits into one profile.

Are cookies dangerous?

Cookies are not viruses and cannot run code, but they raise two real risks: privacy loss through tracking, and account takeover if someone steals a sign-in cookie [1][2].

Because a cookie is just stored data, it cannot install software or read your files [1][5]. Websites can only read their own cookies, not those set by other sites, because the browser sends each cookie only to the domain and path it belongs to [1][3].

The risks are of a different kind:

  • Privacy. Tracking cookies can build a profile of your browsing across many sites, as described above [2].
  • Session theft. MDN notes that a criminal who steals a session ID could make it look as if they are signed in as you, taking control of an online bank or shopping account [1]. Well-built sites reduce this by marking sign-in cookies Secure and HttpOnly, keeping sessions short and asking for your password again for sensitive actions [1].
  • Shared devices. On a public or shared computer, anyone who uses the browser after you may find you still signed in, because your session cookie is still stored.

For most people the practical defence is simple: sign out on shared computers, keep your browser updated and be careful with browser extensions and sites that ask for unusual permissions.

Why do websites ask you to accept cookies?

Mainly because of European and UK law: sites must explain their cookies and get your consent before setting any cookie that is not strictly necessary for the service you asked for [6][7].

In the European Union, the rules come from the ePrivacy Directive together with the General Data Protection Regulation (GDPR) [1][7]. The EU's official business guidance says consent is not needed for cookies used only to transmit a communication or that are strictly necessary for a service you explicitly requested, such as a shopping basket or a sign-in; consent is needed for tracking cookies used for advertising, analytics or market research and for third-party advertising cookies [7]. Those cookies cannot be set when the page first opens, only after you agree; you must be able to consent to each purpose separately, and withdrawing consent must be as easy as giving it [7].

The European Data Protection Board (EDPB), which brings together the EU's data protection authorities, has added two clarifications. A cookie wall, which blocks content until you click accept, does not produce freely given consent; and scrolling or swiping through a page is not a clear, affirmative act of consent [8].

In the UK, the equivalent rules sit in the Privacy and Electronic Communications Regulations 2003 (PECR), enforced by the ICO [5]. Organisations must tell people the cookies are there, explain what they do and why, and get consent for any cookie that is not strictly necessary [5][6]. The ICO notes its guidance is under review after the Data (Use and Access) Act, so details may change [5].

Other places regulate cookies too. MDN lists the California Consumer Privacy Act alongside the EU laws, and notes that such rules can apply to any website that people in those jurisdictions visit [1]. This guide is general information, not legal advice; website owners should check the rules that apply to them.

Should you accept or reject cookies?

Accept the cookies a site needs to work, and feel free to reject optional ones such as advertising and analytics; under EU and UK rules the site should still work for its basic purpose [5][7].

A sensible approach:

  1. Look for a reject or settings button. In the EU, refusing should be as easy as accepting, and you can give separate consent for different purposes [7].
  2. Keep strictly necessary cookies. These are exempt from consent because the site cannot deliver what you asked for without them, for example a basket or a sign-in [7].
  3. Decline advertising and cross-site tracking if you do not want a profile built from your browsing [2][7].
  4. Think about analytics. Analytics cookies help site owners count visitors and fix problems; accepting them is a personal choice [5][7].
  5. Change your mind later. Sites must let you withdraw consent as easily as you gave it, often through a link at the bottom of the page [7].

Rejecting optional cookies rarely breaks a site. If something stops working, such as an embedded video, it is usually a third-party feature that needed its own cookie [1].

How do you view, block and delete cookies?

Every major browser lets you see, delete and block cookies in its privacy settings, including blocking only third-party cookies [5].

The ICO lists the controls available in common browsers [5]:

  • delete all cookies, or those of a single site;
  • block all cookies, or allow all cookies;
  • block only third-party cookies, set by services other than the one you are visiting;
  • clear all cookies whenever you close the browser;
  • open a private or incognito window, which does not keep cookies after the window is closed;
  • install add-ons that extend the browser's privacy features.

Some trade-offs are worth knowing. Blocking all cookies will sign you out everywhere and break many sites, so blocking only third-party cookies is usually the better balance [5]. Private browsing does not make you anonymous: the ICO reminds users that the feature has limitations in a privacy context [5]. The Do Not Track setting found in some browsers asks websites not to track you, but sites are not required to honour it [5].

Browsers also differ in their defaults. According to MDN, Firefox gives each site a separate cookie jar through Total Cookie Protection, which is on by default; Safari's tracking prevention blocks third-party cookies by default; Brave blocks tracking cookies; Edge blocks trackers from unvisited sites and known harmful trackers; and Google Chrome does not block third-party cookies by default except in Incognito mode or if you turn on blocking in its settings [2].

On phones the same controls sit in the browser app's settings, and each app with its own built-in browser may keep separate cookies.

A metal toggle switch flipped off on a desk beside a closed laptop, with small glowing tokens dissolving into sparks
Browser settings let you delete cookies, block third-party cookies or clear them every time you close the browser.

What is replacing third-party cookies?

Browsers keep restricting third-party cookies, so websites are moving to first-party data, partitioned cookies and permission-based access, while the law already covers other ways of storing or reading data on your device [2][6].

MDN tells developers to reduce their reliance on third-party cookies as browsers add restrictions, and documents alternatives: partitioned cookies (known as CHIPS), which get a separate cookie jar for each top-level site so they cannot be shared across sites; the Storage Access API, which asks the user for permission before an embedded service can use its cookies; and gathering data in other ways, such as surveys or a site's own order history [1][2]. Where no SameSite value is set, Chromium-based browsers already treat cookies as Lax by default, which stops most cross-site sending [2].

For everyday users, three points hold whatever the technology: cookies themselves are a basic, useful part of how the web works; the privacy problem is cross-site tracking, not the cookie that keeps you signed in; and the same consent rules in the EU and UK apply to any technology that stores or reads information on your device, not only to cookies [6][7].

Main cookie attributes and what they do
AttributeWhat it controlsExample of use
Expires / Max-AgeHow long the cookie lasts; without them it is a session cookieKeep a user signed in for a set period
Domain / PathWhich addresses receive the cookieShare a cookie across a site's subdomains
SecureSent only over encrypted HTTPSProtect sign-in cookies on public Wi-Fi
HttpOnlyHidden from scripts in the pageReduce theft through cross-site scripting
SameSite (Strict, Lax, None)Whether it is sent with requests from other sitesLimit cross-site tracking and forged requests
First-party vs third-party cookies
FeatureFirst-party cookieThird-party cookie
Set byThe site in your address barAnother domain embedded in the page
Typical usesSign-in, basket, language, site analyticsAds, cross-site analytics, embedded widgets
Can follow you across sites?No, only on that siteYes, wherever the same third party is embedded
Default browser treatmentAllowedRestricted by default in Firefox, Safari and Brave; allowed by default in Chrome
EU consent needed?Only if not strictly necessaryYes, for advertising and tracking purposes
Default handling of third-party cookies in major browsers (as described by MDN, June 2026)
BrowserDefault behaviour
FirefoxTotal Cookie Protection: a separate cookie jar per site, on by default
SafariTracking prevention blocks third-party cookies by default
BraveBlocks tracking cookies by default
EdgeBlocks trackers from unvisited sites and known harmful trackers
ChromeAllows third-party cookies by default; blocked in Incognito or if the user turns blocking on

Common mistakes

  • Thinking cookies are viruses or spyware.

    Fix: Cookies are small pieces of data and cannot run code; the real risks are tracking and stolen sign-in sessions [1][2].

  • Believing private browsing makes you anonymous.

    Fix: It stops cookies being kept after the window closes, but has limits in a privacy context [5].

  • Blocking every cookie to stay private.

    Fix: That breaks sign-ins and baskets; blocking third-party cookies targets tracking with fewer side effects [5].

  • Assuming you must click Accept to use a site in the EU.

    Fix: Cookie walls do not give valid consent; you should be able to refuse optional cookies [7][8].

  • Treating scrolling past a banner as agreement.

    Fix: The EDPB says scrolling or swiping is not valid consent [8].

  • Assuming deleting cookies stops all tracking.

    Fix: Fingerprinting and similar techniques can identify a browser without cookies [5][6].

Frequently asked questions

What are cookies on a website?

Small pieces of data a site asks your browser to store and send back on later visits, so it can remember things like your sign-in or basket [1][5].

What are cookies on the internet used for?

Session management such as sign-ins and baskets, personalisation such as language, and tracking for analytics or advertising [1].

What are cookies on a computer?

Text data stored by your web browser in its own files; each website can read only the cookies that belong to it [1][3].

What are cookies on your phone?

The same thing: the phone's browser stores them, and you can view or delete them in that browser's settings [5].

What are cookies in a browser and how do I clear them?

Your browser stores cookies for each site; its privacy settings let you delete them all, delete one site's, or clear them automatically when you close it [5].

Should I accept all cookies?

You can accept the necessary ones and reject optional advertising and tracking cookies; in the EU refusing should be as easy as accepting [7].

What is a third-party cookie?

A cookie set by a domain other than the site you are visiting, usually through embedded ads, widgets or analytics, which can track you across sites [2][3].

Can cookies steal my passwords?

Cookies do not run code, but a stolen sign-in cookie can let someone into your account, which is why sites mark them Secure and HttpOnly [1].

Glossary

HTTP cookie
A small piece of data a server sends to a browser, which the browser stores and returns with later requests [1].
Session cookie
A cookie without an expiry date, deleted when the browser session ends [1].
Persistent cookie
A cookie with an Expires or Max-Age setting that survives browser restarts until it expires [1].
First-party cookie
A cookie from the same site as the page you are viewing [2].
Third-party cookie
A cookie from a different site whose content is embedded in the page; also called a cross-site cookie [2].
Tracking cookie
A third-party cookie used to build a profile of a person's browsing across sites [2].
Cookie wall
A banner that blocks content until the user accepts cookies; the EDPB says it does not give valid consent [8].
Device fingerprinting
Identifying a device from its combination of settings rather than a stored file; covered by UK cookie rules [5].

Sources

  1. Using HTTP cookies MDN Web Docs (Mozilla) · 2026-11-17
  2. Third-party cookies MDN Web Docs (Mozilla) · 2026-06-15
  3. RFC 6265: HTTP State Management Mechanism Internet Engineering Task Force (IETF)
  4. RFC 2109: HTTP State Management Mechanism Internet Engineering Task Force (IETF)
  5. Cookies Information Commissioner's Office (UK)
  6. Cookies and similar technologies (Guide to PECR) Information Commissioner's Office (UK)
  7. Online privacy: cookies Your Europe, European Union · 2026-08-05
  8. Guidelines 05/2020 on consent under Regulation 2016/679 European Data Protection Board · 2020-05-04
Share this guide Telegram WhatsApp X
0 likes

Comments

Top comments

About the Pouyam Team Editorial policy

On Pouyam

Explore Pouyam

Guides are one corner of Pouyam. Here is where to go next.

Play and win dollar prizes

All games

Free online games with no download on Pouyam: every game earns season points, and the top players win dollar prizes.

Quick navigation