Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do I access the local storage of a URL that I am not currently connected to?

Javascript noob here, please excuse my stupidity-

Is there a way to access the local storage of another URL when I am not actively visiting that site?

If I am on https://www.youtube.com/ and I go to local storage on my browser (Chrome in this case), there are two separate URLs there, one for https://www.youtube.com/ and one for https://accounts.youtube.com/.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I don’t know how to go about accessing this "secondary" local storage, or whatever you would call it, for a website.

FOR EXAMPLE,

When I go to youtube.com, this is what the local storage looks like:

Local Storage Image

Note the two separate URLs in the Local Storage tab.

Each URL has it’s own respective local storage, with different values in each.

Local storage for https://www.youtube.com/
Local Storage for youtube.com

Local storage for https://accounts.youtube.com/
Local Storage for accounts.youtube.com

How would I go about accessing localStorage["foo"] from accounts.youtube.com?

Currently, localStorage["foo"] would just be undefined, because it is looking at the local storage for the primary url (https://www.youtube.com/) but I want to somehow access the "secondary" URL (https://accounts.youtube.com/)

So is there any way for me to access this "secondary" storage using Javascript, or am I simply looking at this the wrong way/misunderstanding something?

>Solution :

As others have said in the comments, this is not possible. It’s by design for security. Here is a pretty decent article that covers the same origin policy, localStorage, and sessionStorage.

https://auth0.com/blog/secure-browser-storage-the-facts/

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading