Localstorage is a particularly useful part of HTML 5 which allows websites to store small amounts of data inside a user's browser in a place that is only accessible to that site. In many ways, it's an extension of the idea behind cookies.

While debugging a LIFDed web application, I tried to do something that should have been simple: dumping all of the data that a site has in localstorage. Unfortunately it wasn't all that straightforward.

Before you do anything else, make sure that persistent cookies are enabled. In Firefox, that means:

Edit | Preferences | Privacy | History | Keep until: they expire

If you don't do this, then the localstorage database on disk will always be empty as I imagine the data is simply kept in a data structure in memory.

However, if you don't like the idea of persistent cookies for privacy reasons, you can still tell Firefox to clear cookies when it shut downs. Simply select "Clear history when Firefox closes" and then click the Settings button next to it. Localstorage will work as expected until the browser is closed.

Reading the contents of localstorage

While there is an addon for this (Foundstone HTML5 Local Storage Explorer), it's proprietary and there is an easy alternative if you're not scared of the command-line:

  1. go into your Firefox profile directory (~/.mozilla/firefox/xxxxxx.default/)
  2. open the database using sqlite3 (apt-get install sqlite3 on Debian):

    sqlite3 webappsstore.sqlite

  3. dump everything that's in this database:

    .dump webappsstore2

  4. or only show the strings from a given origin (e.g. http://127.0.0.1:8000):

    SELECT key, value FROM webappsstore2 WHERE scope = '1.0.0.721.:http:8000';