On this page
- 1 JavaScript: localStorage and sessionStorage
- 2 JavaScript: localStorage and sessionStorage
- 2.0.0.1 Introduction to the DOM
- 2.0.0.2 How to apply CSS to iframe?
- 2.0.0.3 JavaScript Map, Reduce, and Filter
- 2.0.0.4 JavaScript Concepts Everyone Should Learn!
- 2.0.0.5 JavaScript: Array functions/methods
- 2.0.0.6 JavaScript: Array map() Method
- 2.0.0.7 Promise in JavaScript with example
- 2.0.0.8 JavaScript: FormData
- 2.0.0.9 JavaScript: How ES6 Arrow Function Can Help You
- 2.0.0.10 ES6: Spread syntax
- 2.0.0.11 ES6: Spread operator
- 2.0.0.12 ES6: Introduction
- 2.0.0.13 JavaScript: Scope and the Variable this
- 2.0.0.14 JavaScript: Get Element
- 2.0.0.15 JavaScript: JSON (JavaScript Object Notation)
- 2.0.0.16 JavaScript: Application programming interface (API)
- 2.0.0.17 Javascript : Date & Time Program
- 2.0.0.18 JavaScript: What is AJAX?
- 2.0.0.19 JavaScript: Getting started
- 2.1 Leave A Comment Cancel reply
JavaScript: localStorage and sessionStorage
JavaScript: localStorage and sessionStorage
July 9, 2021
HTML web storage provides two objects for storing data on the client:
window.localStorage
– stores data with no expiration datewindow.sessionStorage
– stores data for one session (data is lost when the browser tab is closed)
Before using web storage, check browser support for localStorage and sessionStorage:
if (typeof(Storage) !== "undefined") { // Code for localStorage/sessionStorage. } else { // Sorry! No Web Storage support.. }