Mateu
Mateu

Reputation: 2698

html 5 storage websql, and localStorage : for how long data is stored?

With new Html 5 there are 3 main ways to store data in your browser:

I wanted to know, for each of the types, for how long data is stored? If the user enters the day after, the data will still be there? after one month? and one year?

Thanks

Upvotes: 11

Views: 4625

Answers (2)

Steve Blackwell
Steve Blackwell

Reputation: 5924

  • WebSQL is deprecated. See here.
  • Indexed DB is persistent.
  • localStorage is also persistent (not to be confused with sessionStorage).

'Persistent' comes with the caveat that atornblad pointed out: it's only persistent until the user decides to wipe their own data.

Upvotes: 4

Anders Marzi Tornblad
Anders Marzi Tornblad

Reputation: 19305

The most correct answer to this question is: You don't know.

The user could wipe his/her local data at any time, and any type of local storage is subject to user preferences and to be considered extremely volatile. However, there is no defined expiration time, according to Web Storage specifications:

Expiring stored data

User agents may, if so configured by the user, automatically delete stored data after a period of time.

For example, a user agent could be configured to treat third-party local storage areas as session-only storage, deleting the data once the user had closed all the browsing contexts that could access it.

This can restrict the ability of a site to track a user, as the site would then only be able to track the user across multiple sessions when he authenticates with the site itself (e.g. by making a purchase or logging in to a service).

However, this also reduces the usefulness of the API as a long-term storage mechanism. It can also put the user's data at risk, if the user does not fully understand the implications of data expiration.

Source: http://dev.w3.org/html5/webstorage/

Upvotes: 7

Related Questions