Does CORS affects localStorage?

拈花ヽ惹草 提交于 2019-12-11 07:43:33

问题


Searched everywhere and didn't find straight answer.
Does CORS make cross-(sub)domain localStorage sharing possible or not?
And how about on IE8?


回答1:


No, you cannot directly access another origin's storage, regardless of CORS settings.

You could however have a remote AJAX service that could store your settings on the remote domain.

e.g. Say your main website www.maindomain.com returns header Access-Control-Allow-Origin: https://www.subsite.com for its AJAX requests.

Then your other website www.subsite.com can make an AJAX request to e.g. https://www.maindomain.com/storage to retrieve or to save details cross-origin. The local storage for www.maindomain.com can be returned as a JSON object in the response for www.subsite.com to use.



来源:https://stackoverflow.com/questions/20190114/does-cors-affects-localstorage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!