SessionStorage
ELI5 — The Vibe Check
SessionStorage is just like LocalStorage except it forgets everything when you close the browser tab. It's perfect for temporary state you only need during that one browsing session — like a multi-step form that shouldn't carry over to the next time they visit.
Real Talk
SessionStorage is a Web Storage API identical in interface to LocalStorage, but its data is scoped to a single browser session — it is cleared when the tab or window is closed. It is also isolated per tab, meaning two tabs on the same site do not share SessionStorage.
Show Me The Code
// Store wizard step progress
sessionStorage.setItem('checkoutStep', '2')
// Retrieve it
const step = sessionStorage.getItem('checkoutStep') // '2'
// Cleared automatically when tab closes
When You'll Hear This
Use SessionStorage for multi-step form state within one session.,Unlike LocalStorage, SessionStorage doesn't survive a tab close.,Each browser tab gets its own isolated SessionStorage.
Related Terms
Cookie
A cookie is a tiny piece of data the server tells your browser to store and send back on every future request.
IndexedDB
IndexedDB is a full-on database living inside your browser.
LocalStorage
LocalStorage is a simple key-value storage built into every browser that persists even after you close the tab.