First Visit
Browser
Customer
Server
Store clerk
Browser Storage
Your notebook
🍪 Cookie = Ticket Stub
The store (server) stamps a ticket and gives it to you. Every time you come back, you
automatically show the ticket. The cashier reads it and says "Ah, welcome back!"
📓 LocalStorage = Personal Notebook
You write notes in your own notebook that lives in your bag. The store never sees it — but you
can check it anytime to remember your preferences. It never gets thrown away.
📋 SessionStorage = Sticky Note
You jot something on a sticky note while you're in the store. The moment you walk out (close the tab),
the sticky note goes in the trash.
LocalStorage
Client-side only, persistent
CLIENT
Size Limit:5–10 MB
Sent to Server:❌ Never
Expiry:♾️ Never (manual)
Scope:Origin (domain+port)
Accessible by JS:✅ Always
localStorage.setItem('theme', 'dark');
localStorage.getItem('theme'); // 'dark'
SessionStorage
Per-tab, cleared on close
TAB
Size Limit:5–10 MB
Sent to Server:❌ Never
Expiry:Tab close
Scope:Same tab only
Accessible by JS:✅ Always
sessionStorage.setItem('formStep', '3');
sessionStorage.getItem('formStep'); // '3'
Welcome! Select a scenario and click "Run" to see how the browser stores and
retrieves your data.