What browser cookies actually do (and why every website asks you to accept them)
Invented in 1994 for an online basket, tiny plain-text cookies now run logins, power cross-site adverts, and trigger consent banners worldwide.

Every visit to a modern website begins with the same minor ambush: a pop-up asking you to accept cookies before you can read a recipe, check a train timetable, or open a news story. Most people tap the brightest button just to clear the screen, without really knowing what they have agreed to—or what landed inside their browser a fraction of a second later.
This guide explains where cookies came from, what a cookie actually is, how they keep logins and shopping baskets working, how ad networks turned them into cross-site trackers, why UK and European privacy rules made consent banners ubiquitous, and what is replacing third-party cookies today.
A tiny note written in plain text
Despite its ominous reputation, a browser cookie is not a computer program, spyware, or a hidden virus. It cannot read files on your hard drive, open your webcam, or run code on your device.
A cookie is simply a short plain-text key-value pair—such as session_id=8f3a91c2 or currency=GBP—that a web server asks your browser to hold onto. Most cookies take up only a few dozen bytes, and standards cap each cookie at roughly 4 kilobytes of text while limiting how many any single domain may store.
Browsers need these notes because HTTP, the protocol delivering web pages, is stateless by design. Every click arrives at the server as though a complete stranger knocked on its door for the first time. Without memory, an online shop would forget who you are the instant you moved from a product page to the checkout.
Cookies fix that amnesia neatly. A server replies with a Set-Cookie header containing a text value and expiry rules. On every return request to that domain, your browser automatically sends back a matching Cookie header, letting the server recognise your session or remember your dark-mode choice.
How a shopping basket problem invented the cookie in 1994
The cookie was not built for advertising. It was invented in 1994 at Netscape Communications to solve a practical e-commerce problem.
A 23-year-old Netscape engineer named Lou Montulli was helping the telecoms firm MCI build an early online shop. MCI needed a virtual shopping basket that remembered items across page loads, without forcing MCI's servers to maintain millions of abandoned baskets for visitors who might never pay.
Montulli's answer was to store that basket state on the customer's own computer. Instead of keeping an open database row for every browser on the web, the server handed each visitor a compact text token, and the browser returned it on the next click.
For the name, Montulli borrowed magic cookie from Unix and C programming jargon, where engineers already called a small opaque session token a magic cookie—like a cloakroom ticket that tells the attendant precisely which coat is yours. Montulli and colleague John Giannandrea filed a patent in 1995, and RFC 2109 formalised HTTP cookies in 1997, back when almost every cookie stayed strictly between you and one site.
Session cookies, persistent cookies, and security rules
When a server creates a cookie, it attaches attributes telling your browser when it expires, where it may travel, and whether scripts may read it.
1. Session cookies: These carry no expiry date and live in memory while your visit lasts. Closing the browser deletes them, unless tab-restore keeps the session alive. Sites use them for active logins and temporary baskets.
2. Persistent cookies: These carry an Expires date or Max-Age timer in seconds, so your browser writes them to disk for days or months—powering "remember me" logins and saved language choices.
3. HttpOnly: This flag hides the cookie from JavaScript on the page, blocking malicious cross-site scripts from stealing login tokens.
4. Secure: This flag tells your browser to send the cookie solely over encrypted HTTPS connections, never over open HTTP on public Wi-Fi.
5. SameSite: Using Strict, Lax, or None, this rule governs whether cookies ride along on cross-site links or forms. Modern browsers now default to Lax when omitted, blocking request-forgery attacks and curbing casual tracking.
First-party vs. third-party cookies
Understanding the cookie debate starts with who sets the note.
When you sign in to daily-example.co.uk or save a weather town, the site stores a first-party cookie under daily-example.co.uk. Only that domain can read it back, keeping your account signed in and your preferences intact.
Modern web pages, however, assemble pieces from dozens of outside servers: embedded videos, social buttons, analytics scripts, ad exchanges, and invisible one-by-one tracking pixels. When your browser fetches a script from adnetwork.example, that external server can reply with its own Set-Cookie header—creating a third-party cookie under a domain you never typed into the address bar.
Alone, one third-party cookie reveals little. Scale turns it into tracking. Because the same advertiser network embeds its code across thousands of unrelated blogs, shops, and news sites, your browser sends the same adnetwork.example ID back on every visit. By reading the page address on each request, the broker stitches together a cross-site profile—which is why walking boots you browsed on Tuesday follow you into banner adverts on Thursday.
Why every website asks you to accept cookies
For fifteen years, cookies operated largely out of sight. Europe and Britain changed that.
In 2009, the European Union amended its ePrivacy Directive—dubbed the Cookie Directive—implemented in Britain through PECR and overseen by the ICO. It required informed consent before storing or reading non-essential data on a user's device. Only cookies strictly necessary for a service the user requested, such as a shopping basket or secure login, skipped permission. Analytics and targeted adverts required a clear yes first.
Early compliance was patchy, with vague banners claiming continued browsing counted as consent. Then May 2018 brought the GDPR—now retained in Britain as the UK GDPR—which defined valid consent as freely given, specific, informed, and unambiguous, banning pre-ticked boxes and raising maximum fines to 20 million euros (£17.5 million in the UK) or 4 percent of global annual turnover.
A cookie banner is rarely asking whether a site can remember your basket. It is asking whether dozens of ad intermediaries can follow you across the web.
Because global publishers serve international audiences, maintaining separate sites for the UK, Europe, and everywhere else proved awkward. Ad-tech groups built shared consent frameworks that pass your preference string down the ad-auction chain, and pop-up banners soon became standard worldwide.
Consent dark patterns and why "Reject all" is hidden
If cookie prompts feel exhausting by design, they often are. Many publishers use consent dark patterns to nudge tired readers into tapping yes.
The familiar trick puts a bright Accept all button right under your thumb beside a faint grey Manage preferences link. Opening that menu reveals dozens of partner toggles and a second tab marked Legitimate interest, a legal basis under UK GDPR and EU law that some vendors stretch unless you object to each firm individually.
Watchdogs such as Britain's ICO and France's CNIL eventually made clear that refusing cookies must be as straightforward as accepting them. One tap to accept requires one tap on the first screen to refuse. That pressure pushed many big publishers to display Reject all upfront, though misleading layouts still linger on smaller sites.
What actually changes when you click Reject all
Many readers hesitate to tap Reject all, worried the website will break or empty their basket. Saying no changes far less than banners suggest.
When you decline non-essential cookies, a site is still legally permitted to set strictly necessary first-party cookies. Your login stays active, security tokens protect forms, your shopping basket survives, and the site stores a small preference cookie remembering that you opted out so it stops asking on the next page.
What stops is background tracking. Third-party ad tags quit reading cross-site IDs, retargeting pixels fall silent, social embeds wait until you click, and marketing analytics either switch off or drop to anonymous aggregate counts. You still see adverts on ad-supported sites, just contextual adverts matched to the article in front of you—running trainers beside a marathon guide—rather than adverts chasing your browsing history.
Beyond cookies: local storage and browser fingerprinting
Blocking third-party cookies does not stop every form of tracking.
Modern browsers also provide Web Storage—localStorage and sessionStorage—plus IndexedDB. Unlike cookies, which ride inside HTTP headers on every request, Web Storage keeps megabytes locally for web apps, offline drafts, and player settings. The ICO and European regulators treat non-essential ad IDs stored there identically to cookies, because the law covers any device storage regardless of format.
A stealthier technique stores nothing at all: browser fingerprinting. A script inspects dozens of tiny system clues your browser exposes when loading a page—screen resolution, operating system, time zone, language, fonts, CPU cores, and graphics-card rendering quirks. Combined, they often form a signature distinctive enough to recognise your device across websites even after you clear cookies or open a private window.
How browsers went to war over third-party cookies
Over the past decade, browser makers split sharply over third-party cookies.
Apple moved first: Safari launched Intelligent Tracking Prevention in 2017 and blocked third-party cookies by default in 2020. Mozilla Firefox followed with Enhanced Tracking Protection and Total Cookie Protection, confining each site's cookies to a separate jar so ad scripts cannot link visits across domains.
Google Chrome, with the largest global market share and an ad-funded parent firm, moved much more slowly. In 2020 Google announced a two-year plan to phase out third-party cookies under its Privacy Sandbox initiative. After repeated delays and scrutiny from publishers and competition regulators such as Britain's CMA, Google shifted course in 2024 and 2025—dropping a mandatory cut-off in favour of user-managed browser controls, leaving third-party cookies active for most Chrome users unless they opt out.
Practical habits that actually protect your privacy
You do not need to break websites or retype passwords constantly to curb tracking.
6. Use a browser with cookie isolation: Firefox with Enhanced Tracking Protection or Safari blocks cross-site cookie tracking automatically without disrupting daily logins.
7. Tap Reject all on the first screen: Choose Reject all or Essential only whenever available, and watch out for buried Legitimate interest toggles.
8. Separate sensitive browsing with profiles: Keep banking, work, and healthcare portals in a dedicated browser profile or private window away from casual shopping.
9. Know the limits of Private Browsing: Closing an Incognito window deletes cookies and history from your computer, hiding activity from shared-device users—yet it does not hide your IP address or traffic from websites, employers, or your broadband provider.
10. Skip aggressive cookie-wiping add-ons: Deleting every cookie on tab close signs you out repeatedly and erases the preference cookies remembering your rejections, bringing banners back on every visit.
A small piece of text that shaped the modern web
In 1994, a 4-kilobyte plain-text note solved a neat engineering problem: helping a stateless web remember a shopping basket. Thirty years later, that same simple mechanism underpins bank logins, global ad auctions, and the consent banners we swat away every day.
Understanding what cookies actually do takes the guesswork out of those boxes. A tiny text label inside your browser is harmless on its own—and the real choice is never about the cookie, but about who gets to read it.





