Skip to content
How cookies work

What is a cookie?

A cookie is a tiny piece of text that a website asks your browser to keep. It usually holds little more than a random ID, but it is what lets a site recognise you from one page to the next.

Without cookies, the web would have no memory. Every click would look like it came from a brand new visitor, so you would be logged out on every page and your shopping cart would empty itself.

The same simple idea is also what lets advertisers follow you from site to site, which is why cookies have such a mixed reputation.

Here is the same click on a shopping site, once without cookies and once with one. Watch what the website knows and what happens to your cart.

Without cookies

With a cookie

How cookies work

Step by step

1

You visit a site for the first time

Your browser asks for the page. Since you have never been there before, it has no cookie for that site to send along, so the website has no idea who you are.

2

The site hands your browser a cookie

Along with the page, the website sends a small note that says something like id=7f3a. Your browser files it away under that site's name, usually with an expiry date.

3

Your browser sends it back every time

On every later request to that site, your browser automatically attaches the cookie. The site looks up the ID and knows it is you, which is how you stay logged in and keep your cart between pages.

4

Third-party cookies follow you around

A page can also load pieces from other companies, like an ad or a share button. Those companies can set cookies of their own, and because their pieces appear on thousands of sites, the same cookie lets them spot you on all of them.

On a news site

Later, on a shoe shop

Blocking third-party cookies

Keep the useful cookies, lose the trackers

Most browsers let you block third-party cookies with a single setting. Your logins keep working because those are first-party cookies, while ad networks lose their easiest way to follow you. Tap the laptop to compare.

Third-party: allowedTap the laptop to block third-party cookiesThe site you visitRemembers yourlogin and cartAdAd networksFollow you fromsite to siteSocial buttonsSee where yougo on the web
Kinds of cookie

The cookies you will hear about

Session cookies
Live only until you close your browser. Sites use them for things like keeping you logged in during a single visit.
Persistent cookies
Come with an expiry date, anywhere from a day to a couple of years, so a site can still remember you next week.
First-party cookies
Set by the site in your address bar. These handle logins, shopping carts, language choices and other settings.
Third-party cookies
Set by other companies whose content is embedded in the page, mostly ad and tracking networks that appear on many sites.
Important limits

What cookies can and cannot do

Cookies can

  • Keep you logged in and remember your settings
  • Remember what is in your shopping cart
  • Let ad networks recognise you across sites, when they are third-party

Cookies cannot

  • Run code or carry viruses, since they are just text
  • Read files on your computer
  • Be read by sites other than the one that set them
In short

A cookie is just a name tag your browser carries back to a site, and it is what makes logins and carts work. The trouble comes from third-party cookies, which let ad networks recognise the same name tag everywhere. Blocking third-party cookies stops most of that while the useful cookies keep working, and clearing all your cookies simply logs you out everywhere.

Was this article helpful?

Comments

0

Share your thoughts, questions, or feedback about this guide.

Leave a Comment

0/2000