Web Technologies

How HTTP cookies work: Set-Cookie, SameSite and HttpOnly

How HTTP cookies let a website remember you: Set-Cookie and Cookie headers, session ids, expiry, HttpOnly, Secure and SameSite, and cookies vs localStorage.

  • 7 min read
  • 5 questions
  • +35 XP
Transcript

Cookies explained by cats. Kitty visits a tuna shop website. The shop wants to remember Kitty. Her name, her basket, her favorite fish treats. So it gives Kitty a tiny note. Kitty keeps the note in her pocket. Next time Kitty visits, she shows the note.

The shop instantly knows who she is, what's in her basket, and her favorite tuna flavor. That's a cookie. A small piece of data stored in your browser, sent back with each visit. So the website remembers you. Useful for logins, preferences, and shopping carts. Tiny notes. Big convenience.