ELI5: How do internet cookies work?

An internet cookie is a tiny note that a website leaves in your web browser so it can remember who you are the next time you visit.

Imagine you go to a theme park and get a hand stamp at the entrance. That stamp does not say everything about your life, but when you leave to get lunch and come back, the worker looks at your hand and immediately knows to let you back in without asking for your ticket again. An internet cookie works just like that invisible ink stamp.

Whenever you visit a webpage, your computer and the website have a quick conversation:

  • The Hello: You open a shopping website, and the site creates a tiny text note that says, "This person prefers dark mode and likes toy trains."
  • The Pocket: The website slips this note into your browser's pocket for safekeeping.
  • The Return: When you click to another page or return tomorrow, your browser shows the note back to the site. The site reads it and instantly remembers your saved items and preferences.

Cookies help make everyday web browsing much smoother in several ways:

  • Keeping you logged in: Without first-party cookies, you would have to type your password every single time you clicked on a new page.
  • Saving your shopping cart: If you put a pair of shoes in your virtual cart and accidentally close the window, a cookie makes sure the shoes are still there when you open it back up.
  • Remembering your choices: They save small details like your language preference or your local weather location.

There are also tracking cookies, which work like a friendly shopkeeper who follows you to other stores in the mall. If you look at sneakers on one website, that cookie tells an advertising company, which is why you suddenly see ads for those exact same sneakers on your favorite news site later that day.

Just like emptying your pockets at the end of the day, you can clear these cookies out of your web browser anytime you want a fresh start.

Ask your own question

Opens the question on the homepage. Nothing is sent until you press Explain it.

Follow-up questions

Test yourself

Three quick questions to see if it stuck. You can challenge a friend after.