Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternatives to HTML5 localStorage

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).

like image 868
Journeyman Avatar asked Aug 02 '11 09:08

Journeyman


People also ask

What is localStorage in HTML5?

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.

What are the alternatives to local storage?

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.

What is local storage and how do I use it?

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.

What are some tips for HTML5 offline storage?

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.


2 Answers

With HTML5 your local storage options are limited to the following:

  • localStorage
  • cookies
  • Web SQL (in WebKit and Opera)
  • IndexedDB (in all modern decent browsers)

… however, users can delete data in any of these stores, and that is as it should be.

like image 53
Ben Avatar answered Oct 08 '22 22:10

Ben


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.

like image 35
dimitriosdev Avatar answered Oct 08 '22 22:10

dimitriosdev