
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
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 Articles
- 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)
- Build a Site Bookmark App with JavaScript by using Local Storage
- How to store objects in HTML5 localStorage?
- How to change the local disk name using PowerShell?
- Storing Credentials in Local Storage
- How to save cache in local storage of android webview?
- How to save database in local storage of android webview?
- Difference between Local Storage, Session Storage, and Cookies in JavaScript
- HTML DOM Local Storage clear() method
- How to define a term or name in a definition list using HTML5?
- HTML5 / JS storage event handler
- Retrieve element from local storage in JavaScript?

Advertisements