html5 Local Storage Across Different Browsers
Asked Answered
K

2

16

I did my local storage using Chrome and then try to access it through Firefox. But it’s not there. Can somebody clarify that is it a valid test case to store and retrieve HTML5 local storage using different browsers? As per my understanding HTML local storage path is browser specific. So I assume that you need to use same browsers for both storage and retrieve belongs to a specific KEY. Is it a correct statement?

Koo answered 7/11, 2014 at 6:33 Comment(0)
A
33

Local Storage is "local" in that exact browser and ONLY in that browser. To retrieve something stored in Local Storage, you must use the same browser, the same key and retrieve it from a page in the same origin (e.g. domain).

If you want something available across multiple browsers, then you would usually identify the user somehow (usually a user login) and then you would store the user's data on a server somewhere so that the data can be served to the same user across multiple browsers and even multiple computers/devices.

Appose answered 7/11, 2014 at 6:36 Comment(3)
You wouldn't necessarily need to store the data on a server, since it could be transferred directly between two browsers using WebRTC.Annorah
@AndersonGreen What if both browsers aren't running at the same time?Kessia
There are other ways to transfer data between browsers without identifying the user. I could save localStorage items in the page's URL as search parameters, and load them into any browser from that URL.Annorah
C
3

jfriend00 has correctly answered your question, however, I would like to caveat this by adding that there is a way to access your data on another browser even if its on another device, as long as this browser is Chrome. The way to do this is to use chrome.storage API, which has been available since Chrome 25.

The following are its benefits/features:

  • User data can be automatically synced with Chrome sync (using storage.sync).
  • Your extension's content scripts can directly access user data without the need for a background page.
  • A user's extension settings can be persisted even when using split incognito behavior.
  • It's asynchronous with bulk read and write operations, and therefore faster than the blocking and serial localStorage API.
  • User data can be stored as objects (the localStorage API stores data in strings).
  • Enterprise policies configured by the administrator for the extension can be read (using storage.managed with a schema).

Here is the Documentation

Cibis answered 11/8, 2018 at 4:9 Comment(2)
is there a way to use this in a web app, it seems the documentation refers only to chrome extension developers..Embayment
It can't be used in web appProximate

© 2022 - 2024 — McMap. All rights reserved.