Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firefox localStorage how to access it across all tabs?

I am only concerned with mozilla's use of localStorage. When i store strings into localStorage

example:

on tab A, I insert:

localStorage["item"] = "hello";

on tab B, I request the same item using

localStorage.getItem("item");

I cannot access this item for some reason in Tab B if i set the the value in Tab A, however i have used the same code in Google Chrome before and it has shown Global characteristics.. why does it not work in Mozilla Firefox the same way?? Other stackoverflow threads have said to use globalStorage but that is a deprecated method according to documentation.

Thanks,

Aiden

like image 642
Aiden Avatar asked Oct 08 '13 03:10

Aiden


People also ask

Is local storage available to all tabs?

localStorage demo The main features of localStorage are: Shared between all tabs and windows from the same origin. The data does not expire. It remains after the browser restart and even OS reboot.

How do I share session storage between tabs?

You can use localStorage and its "storage" eventListener to transfer sessionStorage data from one tab to another. This code would need to exist on ALL tabs. It should execute before your other scripts.

How do I access local storage in Firefox?

To inspect your localStorage items you may type console. log(localStorage); in your javascript console (firebug for example or in new FF versions the shipped js console). Note that in recent versions Firefox has a built-in JavaScript console ("Web Console"), so one doesn't have to install Firebug to do this.

Where does Firefox save local storage?

The DOM storage data is stored in the webappsstore. sqlite file in the profile folder. The profile folder is located in %APPDATA%\Mozilla\Firefox\Profiles\​ , named something like 321edcba. default , and within it, there's the webappsstore.


1 Answers

What you may try is to set the localStorage value as:

localStorage.setItem("item", "hello");

or

localStorage.item = "hello"

According to the specification all documents with the same origin share the same localStorage data (regardless of the origin of the scripts that actually access localStorage). They can read each other’s data. And they can overwrite each other’s data. But documents with different origins can never read or overwrite each other’s data (even if they’re both running a script from the same third-party server).

This means that you should be able to access the same localStorage date from different tabs.

like image 100
Endre Simo Avatar answered Oct 23 '22 03:10

Endre Simo