html5 Local Storage Across Different Browsers

后端 未结 2 1445
忘了有多久
忘了有多久 2020-12-10 04:51

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 HT

相关标签:
2条回答
  • 2020-12-10 05:09

    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

    0 讨论(0)
  • 2020-12-10 05:22

    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 have to identify the user somehow (usually a user login) and then you need to store the data on a server somewhere so that the data can be served to the same user across multiple browsers.

    0 讨论(0)
提交回复
热议问题