HTML Tutorial

Coming Tutorials

>Home> HTML Tutorial> Web Storage

WWW Tutorial

Coming Tutorials



Web Storage?

The Web Storage store user data locally on web browser. It can be store huge data with security without affecting performance of appication. Web storage based on two objects like Local Storage and Session Storage.

Both the storage are almost same except the data persistent time. The web browser does not send data from these storage to server unlike coockie.


1) window.localStorage :

The Local Storage Stores data with no-expiry date. When the browser closed user search data will not be closed. It will be available when you open it means next day, next months, next year. For accessing data you need to use "setItem" and "getItem" method. The data in local storage would persist even when the user’s browser is closed and reopened.

• localStorage.setItem(key, value) :: It always key-value pair, It stores value related to key.

• localStorage.getItem(key) :: It stores value related to key.

• localStorage.removeItem(key) :: You can be remove stored item from storage using 'removeItem' method with key value.

• localStorage.clear() :: You can be clear all stored data from storage using 'clear()' method.



2) window.sessionStorage :

This is similar to local storage, except that the session storage stores data only for one session. Whwn you closed the browser user search data will be deleted.

Share the article to help your friends


 Previous Topic
Next Topic