How to use Delete Web storage in HTML5

In this article, I will go to explain Delete Web storage in HTML5.
  • 2378

Delete Web Storage in HTML5

  • Storing sensitive data on local machine could be dangerous and could leave a security hole.

  • The Session Storage Data would be deleted by the browsers immediately after the session gets terminated.

  • In Local Storage, you want to clear setting, you would need to call localStorage.remove('key'); where 'key' is the key of the value you want to remove.

  • In Local Storage, you want to clear all settings, you need to call localStorage.clear() method.


Following is the code which would clear complete local storage




  <script type="text/javascript">


      if (localStorage.hits)


          localStorage.hits = Number(localStorage.hits) + 1;




          localStorage.hits = 1;


      document.write("Total Number of Hits :" + localStorage.hits);


  <p>Refreshing the page would not to increase hit counter.</p>

  <p>Close the window and open it again and check the result.</p>




delete storage.jpg

Further Readings

You may also want to read these related articles :

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

© 2020 DotNetHeaven. All rights reserved.