Storing and Reading Data
Use setItem, getItem, and removeItem.
Browser Key-Value Storage
Web Storage gives each origin a simple key-value store in the browser. The two APIs, localStorage and sessionStorage, share the same methods and store only strings.
Writing With setItem
Save a value with setItem(key, value). Both arguments are strings.
localStorage.setItem("theme", "dark");
localStorage.setItem("username", "ada");All lessons in this course
- Storing and Reading Data
- localStorage vs sessionStorage
- Storing Objects with JSON
- Storage Events and Limits