๐Ÿช Cookies Explained Like You're 5

Published: (February 7, 2026 at 05:29 PM EST)
2 min read
Source: Dev.to

Source: Dev.to

The Club Wristband

You go to a club. Pay at the door. Get a wristband.

Now you can:

  • Leave and come back
  • Staff knows you already paid
  • No need to pay again

Cookies are digital wristbands!

How They Work

  • You visit a website
  • The website gives your browser a โ€œcookieโ€ (a small piece of data)
  • Next time you visit, the browser sends the cookie back

The website recognizes you!

Visit 1: "Here's your cookie: user=alex"
Visit 2: Browser shows cookie โ†’ "Welcome back, Alex!"

What Cookies Store

  • Login status (so you stay logged in)
  • Shopping cart items
  • Preferences (dark mode, language)
  • Tracking info (ads use this)

Types

TypeWhat it means
SessionTypically lasts for the current browsing session (but some browsers can restore them)
PersistentHas an expiry time/date; can last days/weeks/months
Thirdโ€‘partySet by a different site than the one youโ€™re visiting (often used for ads/analytics)

Privacy Concerns

Cookies can be used for tracking across websites. Thatโ€™s why many sites ask:

โ€œDo you accept cookies?โ€ ๐Ÿช

In One Sentence

Cookies are small pieces of data websites store in your browser to remember who you are and your preferences.


๐Ÿ‘‰ Full deepโ€‘dive with code examples

0 views
Back to Blog

Related posts

Read more ยป

REST API (Work In Progress)

markdown !Prasun Chakrabortyhttps://media2.dev.to/dynamic/image/width=50,height=50,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws....