Home > UI/UX Development > HTML > Web Storage in HTML5

Web Storage in HTML5

Web Storage

  • Using Web Storage we can store data within web browser.
  • Within Web Storage we can stored large amount of data locally.
  • Data within Web Storage is secured.

Objects in Web Storage

  • window.localStorage – can not expire data(even if we can removed it).
  • window.sessionStorage – data lost when browser tab closed.

Methods in Web Storage

  • setItem(name, value) – Create/add data in localStorage/sessionStorage. Contains name and value.
  • getItem(name) – get/retrieve data from localStorage/sessionStorage.
  • removeItem(name) – remove data from localStorage.

NOTE: removeItem() method is only applicable for localStorage to remove data. sessionStorage data lost when browser tab close.

Example

Store data in localStorage

Get data form localStorage

Remove item from localStorage

 

 

 

This Article is TAGGED in . BOOKMARK THE permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">