What are my alternatives to localStorage for persisting key/value pairs on the client? Ideally I'm looking for something that the user can't inadvertently delete (as they theoretically could with localStorage).
LocalStorage is an HTML5 web storage object for storing data on the client – that is, locally, on a user’s computer. Data stored locally has no expiration date and will exist until it’s been deleted. (In contrast, session storage, which is another HTML5 web storage API, deletes data stored when the browser closes.) Local storage is pure JavaScript.
A few alternatives to local storage do exist depending on whether or not the information is sensitive. Developers who don’t want to use local storage may: Use server-side sessions for sensitive information: Storing data on the server has several advantages when it comes to sensitive information.
Heck, you might not even be familiar with what local storage is, let alone be using it to store your session information! Let’s start with the basics: local storage is a new feature of HTML5 that basically allows you (a web developer) to store any information you want in your user’s browser using JavaScript.
HTML5 Local Storage: Useful Tips 1 Just like cookies, HTML5 offline storage shouldn't be used to store sensitive information (e.g., user IDs or payment information). ... 2 When downloading huge files, you may encounter an error called Out of HTML5 Offline Storage Space. ... 3 Web workers cannot use the data kept in local storage in HTML.
With HTML5 your local storage options are limited to the following:
… however, users can delete data in any of these stores, and that is as it should be.
An alternative could also be localForage, a js library that provides the ease of use of localStorage with all the advanced features of IndexedDB.
One of the benefits: you don’t have to convert your data structures to JSON in order to save them in the datastore.
Its API has support for ECMAScript 6 Promises, which provide a better way of handling asynchronous code. Unfortunately it doesn’t work well with any IE under 11.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With