Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does Firefox store javascript/HTML localStorage?

Tags:

I have made an advanced functional prototype of a simple web application, and delays have pushed this into the position of going "live".

At the moment, it just uses JavaScript's localStorage facility to keep track of what's happening, but due to paranoia, we don't want it to be corrupted causing loss of data (it certainly feels a bit sketchy never talking to a server).

Where does Firefox keep its localStorage database (I think it's SQLite, but I just can't find it)?

like image 881
Stephen Avatar asked Aug 16 '11 13:08

Stephen


People also ask

Where is JavaScript localStorage stored?

Firefox stores localstorage in webappsstore. sqlite file in the profile folder.

Does Firefox have localStorage?

localStorage in extension code. Firefox clears data stored by extensions using the localStorage API in various scenarios where users clear their browsing history and data for privacy reasons. Data saved using the storage. local API is correctly persisted in these scenarios.

Where is HTML5 local storage located?

From the JavaScript code, HTML5 local storage may be accessed through a localStorage object on the global window object. The localStorage object stores the data without any expiration date. The data is not wiped, even after closing the browser, and may be accessed at any time.

Where does window localStorage store data?

LocalStorage is a datastore available in browsers. Data is stored as key/value pairs of strings, and each domain has access to its LocalStorage. When storing JavaScript objects, be sure to correctly convert them to a string with JSON. stringify() before saving.


2 Answers

The DOM storage data is stored in the webappsstore.sqlite file in the profile folder.

§ localStorage

like image 100
Vlad Avatar answered Oct 21 '22 09:10

Vlad


On Mac OS X, the webappsstore.sqlite is located under ~/Library/Application Support/Firefox/Profiles/xxxxxxxx.default/ (where xxxxxxxx is random according to Firefox Profile Tutorial ).

I used the Command Line Shell For SQLite to look around. Assuming www.example.com was a real site and the only site using localstorage, you can run these commands:

$ sqlite3 webappsstore.sqlite sqlite> .tables webappsstore2 sqlite> .schema CREATE TABLE webappsstore2 (scope TEXT, key TEXT, value TEXT, secure INTEGER, owner TEXT); CREATE UNIQUE INDEX scope_key_index ON webappsstore2(scope, key); sqlite> select * from webappsstore2; moc.elpmaxe.www.:http:80|stringkey|value|0| moc.elpmaxe.www.:http:80|jsonkey|{"key","value"}|0| sqlite> .exit 

See How is HTML5 WebStorage data physically stored? for the Chrome storage location. Chrome uses individual sqlite files per hostname and protocol, where Firefox uses the reversed hostname and protocol in the scope column.

See Where the sessionStorage and localStorage stored? for the Opera storage location. Opera uses an XML index file and individual XML files for the Base64 encoded data.

like image 22
Kevin Hakanson Avatar answered Oct 21 '22 09:10

Kevin Hakanson