Skip to main content

Web Storage: localStorage, sessionStorage, Cookies, IndexedDB

Learn Web Storage: localStorage, sessionStorage, Cookies, IndexedDB (Phase 12 · Browser APIs and Web Storage (Important), JavaScript) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

Storing data in the browser • localStorage : key-value strings (about 5 MB), persists until cleared, shared by tabs of the same origin. sessionStorage : the same, but per tab and cleared when it closes. • Values are always strings, so use JSON.stringify / JSON.parse for objects. The API is synchronous, so keep it small. • Methods: setItem , getItem (returns null if missing), removeItem , clear .

More lessons in Phase 12 · Browser APIs and Web Storage (Important)