All topics / Browser Storage and Cookies

Browser Storage and Cookies

How browsers remember things between page loads: cookies and their security attributes, localStorage/sessionStorage/IndexedDB, and which one to reach for depending on what you're storing.

Download EPUB
  1. Cookies: What They Are and Why They Got Complicated A cookie is a small name=value string the browser stores and automatically attaches to every matching request - and that automatic behavior is both why cookies power login sessions and why they're a security surface.
  2. localStorage, sessionStorage, and IndexedDB Three client-side storage APIs that, unlike cookies, never get sent over the network: localStorage persists indefinitely, sessionStorage dies with the tab, and IndexedDB handles the size and structure localStorage can't.
  3. Choosing the Right Storage for the Job A decision guide for picking cookies, localStorage, sessionStorage, or IndexedDB based on what the data is and who needs to see it - worked through with a complete dark mode example.