Where does Firefox store the sessionStorage content
Asked Answered
V

1

7

I am trying to find out where Firefox stores the sessionStorage content but have been unable to find so. I am expecting it to be in a SqLite database like the localStorage content is stored but I have not been able to find it.

So far, I have searched all the typical ".sqlite" files in the profile folder such as cookies.sqlite and content-prefs.sqlite etc but they do not seem to have the sessionStorage data.

I also tried to open the special in-memory database that Firefox supposedly creates - https://developer.mozilla.org/en/XPCOM_Interface_Reference/mozIStorageService#openSpecialDatabase%28%29 but I could not find a way to enumerate the tables present in the database. I could get a connection to the in memory database but i have no clue as to how to figure out the tables etc. that are present in that in-memory database...

Any help is appreciated

Thanks,

Vara answered 27/9, 2011 at 22:3 Comment(0)
S
5

localStorage data is saved in the file webappsstore.sqlite in the Firefox profile. There is a funny tweak that host names are reverted (gro.allizom instead of mozilla.org) but other than that it is pretty much what you would expect. There is only one table:

CREATE TABLE webappsstore2 (
  scope TEXT,
  key TEXT,
  value TEXT,
  secure INTEGER,
  owner TEXT
)

Note that this structure might change in a future Firefox version.

As to sessionStorage, it only needs to persist for one browser session. Restarting the browser normally clears it, so it doesn't need to be stored in a database. Firefox still writes it to disk to allow restoring the current browsing session, namely to the sessionstore.js file (JSON format). There is a key storage, its value is a map from URLs to their corresponding sessionStorage data. I am not sure whether this data is complete however given that its main purpose is to recover from crashes.

Sweatshop answered 28/9, 2011 at 9:34 Comment(4)
That table (webappsstore2 in webappsstore.sqlite) stores the localStorage data. It does not seem to contain the sessionStorage data. Are you certain that it contains sessionStorage data as well bscause I am looking at that table and it only contains localStorage data. I am using Firefox 6.Vara
@user967973: Sorry, my bad - I misread your question, this database is for localStorage data of course. Why do you assume that sessionStorage is stored anywhere on disk? It is usable for one browser session only so I am pretty certain that it is only stored in memory. Will change my answer.Sweatshop
For information, sessionstore.js is now called sessionstore.jsonlz4 and you will need to use a tool like dejsonlz4 (github.com/avih/dejsonlz4) if you want to decode the file to read it.Herwick
I also noticed a bug since Firefox 57, sessionStorage is not restored correctly: bugzilla.mozilla.org/show_bug.cgi?id=339445#c27Herwick

© 2022 - 2024 — McMap. All rights reserved.