Browser cookies explained
Updated · CSD London, East Sheen
Cookies have a worse reputation than they deserve, and a more complicated one than most explanations allow. They are not programs, they cannot infect anything, and some of them are the reason websites work at all. The distinction that matters is not cookies versus no cookies — it is whose cookies.
What a cookie actually is
A small text file a website asks your browser to keep, and hands back the next time you visit. It cannot run, it cannot contain a virus, and it can only be read by the site that set it. That is the whole mechanism. Everything that follows is about what sites choose to store in them.
The useful ones
Without these, ordinary browsing would be miserable.
- Keeping you logged in, so you are not asked for a password on every page
- Remembering what is in a shopping basket as you move around a shop
- Holding your language, currency or accessibility preferences
- Remembering that you already dismissed a cookie banner
- Security functions, including recognising that a login came from this device before
The ones people object to
The difference is first-party versus third-party. A cookie set by the site you are actually visiting is first-party, and is usually doing one of the jobs above. A third-party cookie is set by some other company whose code is embedded in the page — an advertising network, typically — and because the same network appears on thousands of sites, it can follow you across all of them and build a picture of where you go. That is the tracking people mean when they say cookies are bad. Browsers have been steadily restricting it: Safari and Firefox block third-party cookies by default, and Chrome has been curtailing them.
What the consent banners are for
UK and EU law requires sites to get your permission before setting anything not strictly necessary to make the site work. That is why the banners exist. Two practical points: "Reject all" is a valid choice and the site must still function, and where there is only "Accept" and a "Manage preferences" buried behind a second click, the second click is usually where the tracking is switched off. A site that will not work at all without accepting advertising cookies is not complying.
Should you clear them?
Occasionally, and for a specific reason rather than as routine maintenance. Clearing cookies logs you out of everything and resets preferences, so it is not free. It is genuinely worth doing when a site misbehaves — a page that will not load properly or a login that loops is very often a corrupted cookie, and clearing that site’s data fixes it. It is also sensible on a shared or public computer. What it will not do is speed up your machine or remove malware; if something is actually wrong with the computer, cookies are not the cause.
Common questions
- Are cookies dangerous?
- No. A cookie is a small text file, not a program — it cannot run or carry a virus, and only the site that set it can read it. The legitimate concern is privacy rather than security: third-party advertising cookies can track your browsing across many different sites.
- What is the difference between first-party and third-party cookies?
- A first-party cookie is set by the site you are visiting and usually does something useful, such as keeping you logged in. A third-party cookie is set by another company whose code appears on the page, often an advertising network, and because it appears on many sites it can follow you between them.
- Should I accept or reject cookies on those banners?
- Rejecting non-essential cookies is a valid choice and the site must still work. Necessary cookies are set regardless because the site cannot function without them. Where a banner offers only "Accept" prominently, the option to decline is usually behind "Manage preferences".
- Does clearing cookies speed up my computer?
- No. Clearing cookies logs you out of sites and resets preferences, and does nothing for performance. It is worth doing when a particular website misbehaves, which is often a corrupted cookie, but a genuinely slow computer has a different cause.