A wristband at a club
Day 44 of 149
๐ Full deep-dive with code examples
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
- Website gives your browser a "cookie" (a small piece of data)
- Next time you visit, browser shows the cookie
- 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
| Type | What it means |
|---|---|
| Session | Typically lasts for the current browsing session (but some browsers can restore them) |
| Persistent | Has an expiry time/date; can last days/weeks/months |
| Third-party | Set 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.
๐ Enjoying these? Follow for daily ELI5 explanations!
Making complex tech concepts simple, one day at a time.
Top comments (0)