2

Kind of a weird question, but here's the basic situation.

A while back I wrote a basic little todo app for use by some coworkers on an internal corporate network, and I was hosting it on a shared drive. For the sake of persistence without having to set up a web server, user data was being stored in the browser's localStorage.

Recently, the SysAdmins have been reworking the network drive addressing system, which has resulted in a change to the URL for my little app. Of course, this means that the page no longer has access to the same localStorage obejct, and anyone who has been using my app has now "lost" their data, even though it's still stored somewhere by Firefox. (We're all using Firefox 31 on Windows 7, in case that changes anything.)

So the question is, can I retrieve that localStorage data? My first thought, kludge though it is, was to have a user add an entry to their hosts file to point the old URL to another file that will export the data (or, for that matter, point to a trivial file and grab the data manually in the web console). But, as you might have guessed, the hosts file is locked down and we don't have admin rights.

As a final note, I am aware of the various Firefox addons that help with localStorage, but as I mentioned before this is all happening on an isolated corporate network, so bringing in an addon for such a trivial reason is a non-starter.

Thoughts?

1 Answer 1

3

For posterity, I found that localStorage data is stored in a sqlite file called webappsstore.sqlite in your Firefox profile directory. On Windows, this can be found at %APPDATA%\Mozilla\Firefox\Profiles\{profile ID}\webappsstore.sqlite. To read its contents I used a little Python script that uses the sqlite3 package:

import os, sqlite3
profiles = os.path.join(os.environ('APPDATA'),'Mozilla\\Firefox\\Profiles')
profile = os.path.join(profiles, os.listdir(profiles)[0])
db = os.path.join(profile,'webappsstore.sqlite')
print([entry.encode('utf-8') for entry in sqlite3.connect(db).iterdump()])

(I used Python 3, not sure if there are differences in the Python 2 version of sqlite3.)

This will output a lot of data; I recommend redirecting into a file. The data will be in SQL data creation statements. Each entry in local storage has a domain and key associated with it in a table. The URL is always written backwards in the database. You're looking for something like the following:

INSERT INTO "webappsstore2" VALUES('moc.elpmaxe.www.:https:443','myLocalStorageKey','{"key":"value","pairs":["go","here"]}')

You'll find your localStorage key-value pairs somewhere in the output.

2
  • 1
    !rewsna lufesu siht rof sknahT
    – NVRM
    May 29, 2018 at 20:08
  • 1
    You can also download the free DB Browser for SQLite from sqlitebrowser.org and browse through the webappsstore2 table.
    – pbarney
    May 15, 2020 at 20:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.