0

localStorage in HTML5 is a good way to store some insensitive information that can be persisted across pages even after closing and reopening any web page. localStorage API provides localStorage.clear() to clear all the data stored. My question is, does it clears all data stored by other sites which is also performing some transactions based on localStorage. If so then using localStorage is not good idea right??

1 Answers1

2

The LocalStorage is based on the domain. So when you have the local storage cleared, it will be cleared for that domain. If you are using file:/// protocol (opening files) then everything is cleared.

From the spec:

The localStorage object provides a Storage object for an origin.

User agents must have a set of local storage areas, one for each origin.

An origin is a single domain. This means, www.example.com has it's own and example.com has it's own.

Related: In HTML5, is the localStorage object isolated per page/domain?

Community
  • 1
  • 1
Praveen Kumar Purushothaman
  • 154,660
  • 22
  • 177
  • 226