freecoding.school100% FREE · NO SIGNUP
Await StationISSUE #19 of 26

sessionStorage · tab-scoped

PromissaVSRace Condition Rex
Promissa sayssessionStorage works like localStorage but clears when the tab closes.

Same API as localStorage (setItem/getItem/…), but scoped to the tab/session: data vanishes when the tab closes and isn't shared between tabs. Use it for per-session state — a multi-step form's progress, a one-visit flag — anything that shouldn't outlive the tab.

Power-ups you unlock

Race Condition Rex attacks — common mistakes

Boss battleStore a value in sessionStorage and note it’s gone after closing the tab.

Example code

<!doctype html><html><head><meta charset="utf-8"></head>
<body style="background:#06040d;color:#e6e0ff;font-family:monospace;padding:20px"><pre id="o"></pre>
<script>sessionStorage.setItem('visited','yes');
document.getElementById('o').textContent='session flag: '+sessionStorage.getItem('visited')+' (gone when tab closes)';</script></body></html>
▶ Open the interactive comic issue
‹ LocalStorage · Key-Value PersistenceIndexedDB · The Browser Database ›