0

I'm looking at JS code that uses localStorage.getItem() and localStorage.setItem(). It's storing items somewhere, but I can't find out where.

When I go here (using Mac Chrome):

~/Library/Application Support/Google/Chrome/Default/Local Storage/

there is leveldb but I can't find where the exact items are being stored.

This is the exact code:

if (!localStorage.getItem('myapp')){
    localStorage.setItem('myapp', JSON.stringify({next: 0, items: []}));
}
SilentDev
  • 20,997
  • 28
  • 111
  • 214
  • 3
    In Chrome in Developer tools, the Tab Application has it there. – Keith Jan 27 '19 at 21:15
  • @Our_Benefactors Ah, yes.. Well it looks like the correct directory.. OP: Are you saying there are no files in that directory? – Keith Jan 27 '19 at 21:27
  • @Keith there are .ldb files, manifest file and log file. Is it one of the .ldb files? (I have to look through all of them and look for the one that was set through the JS code?) – SilentDev Jan 27 '19 at 21:43
  • @Keith Alex put a good link and Daniel answered it below. Their answer was what I needed. Thanks. – SilentDev Jan 27 '19 at 21:45

1 Answers1

2

For example in Google Chrome:

1) open console.

2) go to the Application

3) open storage -> local storage

4) you should see a table with keys and values

enter image description here

If you asking about "when it is stored on computer disc" it depends from browser and system:

How is HTML5 WebStorage data physically stored?

Where does PERSISTENT file system storage store with chrome?

Where in the filesystem does IE8 store values stored in localStorage?

Daniel
  • 7,684
  • 7
  • 52
  • 76