cross domain localstorage with javascript

后端 未结 4 1711
挽巷
挽巷 2020-12-09 03:11

We have a javascript api.js which is hosted on domain api.abc.com. It manages the local storage.

We included this javascript in our websites at abc.com and login.abc

4条回答
  •  情话喂你
    2020-12-09 03:33

    As noticed in your post the localStorage (sessionStorage too) won't be stored on the storage related to the domain api.abc.com. If this was the case, by using CDN version of a library using localStorage you would have to share storage with all the other websites using this library.

    One good solution could be to use an iframe with postMessage as explained in the following stack overflow: use localStorage across subdomains

提交回复
热议问题