Web Storage API Concepts and Usage

The Web Storage API provides two mechanisms for storing data:

  1. sessionStorage:
    • Maintains a separate storage area for each origin during the page session (as long as the browser remains open, including page reloads and restores).
    • Stores data only for the current session, meaning it persists until the browser or tab is closed.
    • Data is never transferred to the server.
    • The storage limit is larger than that of cookies (up to 5MB).
  2. localStorage:
    • Persists even when the browser is closed and reopened.
    • Stores data with no expiration date and gets cleared only through JavaScript or by clearing the browser cache or locally stored data.
    • The storage limit is greater than that of sessionStorage.

Both mechanisms are accessible via the Window.sessionStorage and Window.localStorage properties. Invoking one of these properties creates an instance of the Storage object, which allows you to set, retrieve, and remove data items.

Web Storage API

Web API Storage facilitates the feature of storing data within the browser on the client side. It is also referred to as web storage. It uses a key-value pair format to store the data.

Table of Content

  • Web Storage API Concepts and Usage
  • Web Storage API Interfaces
  • Examples Showing of Web Storage API

Similar Reads

Web Storage API Concepts and Usage

The Web Storage API provides two mechanisms for storing data:...

Web Storage API Interfaces

Storage: It provides access to a particular local storage. Window: It is a window containing a DOM document. StorageEvent: It is implemented by a storage event which is sent to a window when a storage area changes....

Examples Showing of Web Storage API

1. Using sessionStprage setItem Method:...

Contact Us