- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to delete Web Storage?
Storing sensitive data on local machine could be dangerous and could leave a security hole. The Session Storage Data would be deleted by the browser immediately after the session gets terminated.
To clear a local storage setting you would need to call localStorage.remove('key'); where 'key' is the key to the value you want to remove. If you want to clear all settings, you need to call localStorage.clear() method.
<!DOCTYPE HTML> <html> <body> <script> localStorage.clear(); // Reset number of hits. if( localStorage.hits ){ localStorage.hits = Number(localStorage.hits) +1; } else{ localStorage.hits = 1; } document.write("Total Hits :" + localStorage.hits ); </script> <p>Refreshing the page would not to increase hit counter.</p> <p>Close the window and open it again and check the result.</p> </body> </html>
Advertisements