

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 store a name permanently using HTML5 Local Storage?
The Local Storage is designed for storage that spans multiple windows and lasts beyond the current session. In particular, Web applications may wish to store megabytes of user data, such as entire user-authored documents or a user's mailbox, on the client side for performance reasons.
HTML5 localStorage saves string data in the browser and lasts beyond the current session. localStorage stores the data, with no expiration, whereas sessionStorage is limited to the session only. When the browser is closed, the session is lost.
The data won’t get deleted when the browser is closed. Here, we will save the name for example.
You can try to run the following code to learn how to store a name permanently using HTML5 local storage
Example
<!DOCTYPE html> <html> <body> <div id = "demo"></div> <script> if (typeof(Storage) !== "undefined") { localStorage.setItem("name", "John"); document.getElementById("demo").innerHTML = localStorage.getItem("name"); } else { document.getElementById("demo").innerHTML = "The browser do not support Web Storage"; } </script> </body> </html>
- Related Questions & Answers
- Trick to store credentials in local storage
- Difference between Session Storage and Local Storage in HTML5
- Checking if a key exists in HTML5 Local Storage
- Thread-local storage (TLS)
- How to change the local disk name using PowerShell?
- Storing Credentials in Local Storage
- HTML DOM Local Storage clear() method
- How to save cache in local storage of android webview?
- How to save database in local storage of android webview?
- HTML5 / JS storage event handler
- Retrieve element from local storage in JavaScript?
- Android 4.0.1 breaks WebView HTML 5 local storage?
- C++ program to store student roll and name using map STL
- Convert coordinates to a place name with HTML5
- How to Delete Data Permanently from a PC?
Advertisements