Search code examples
local-storagegoogle-chrome-devtoolsfirefox-developer-tools

Inspect LocalStorage of other sites using Chrome / Firefox devtools


Are there any possible ways we can use devtools of Chrome / Firefox to inspect LocalStorage object of site http://example.com, when we are currently on http://example2.com ? Seems like they only allow to inspect on same site for now.

The story is, I'm working on an authentication function which involves lots of redirecting, and I need to check if the page is redirected, is the LocalStorage data correct or not.


Solution

  • The Chrome as well as the Firefox DevTools currently (as of Chrome 87 and Firefox 84) only allow to inspect the local and session storage data of the current page context.

    Also, as far as I know, there is no other integrated option to inspect all the data saved for a specific domain or URL without navigating to it first.

    So the proper way to inspect such data is to avoid those redirects from happening. Though there's no tool I'm aware of that can stop all redirects. That's why I've asked for it in Mozilla's discussion forum.

    None the less, in Firefox, there's one (admittedly quite complicated) way to inspect the data saved for a specific domain. Firefox saves all local storage data in an SQLite database. This database can be read by any tool that allows to open SQLite files. (There are even browser add-ons allowing to read them.) Here are the steps how to access the data:

    1. Go to about:support

    2. Click the "Open Folder" button besides the "Profile Folder" label => Opens the folder of your current Firefox profile in the operating system's navigator.

    3. In the folder, search for the file webappsstore.sqlite

    4. Open the file in an SQLite managing tool.

    5. Execute the following query to see the data related to the domain http://example.com

      SELECT key, value FROM webappsstore2 WHERE originKey = 'moc.elpmaxe.:http:80'
      

      You may already see it but the domain name saved in the originKey column is the other way round. I don't know why. So the format is <domain name with dot at the beginning the other way round>:<protocol>:<port>.