
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
Storing Credentials in 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.
For storing credentials in local storage, on successful login, generate a completely random string unrelated to user credentials. You need to store this in the database. Do not forget to add an expiry date. Pass that string to the JavaScript to be stored in local storage.
As long as the local storage credential matches the database and the timeout did not expire, consider them logged in.
Therefore, no risk of the user's credentials exposed from local storage.
- Related Articles
- Trick to store credentials in local storage
- Thread-local storage (TLS)
- Difference between Session Storage and Local Storage in HTML5
- Difference between Local Storage, Session Storage, and Cookies in JavaScript
- Retrieve element from local storage in JavaScript?
- HTML DOM Local Storage clear() method
- Checking if a key exists in HTML5 Local Storage
- Set the value in local storage and fetch – JavaScript?
- Android 4.0.1 breaks WebView HTML 5 local storage?
- How to save cache in local storage of android webview?
- How to save database in local storage of android webview?
- HTML 5 local Storage size limit for sub domains
- What is the difference between local storage vs cookies?
- How to store a name permanently using HTML5 Local Storage?
- Build a Site Bookmark App with JavaScript by using Local Storage

Advertisements