[程序员] 2022 年,各位大佬 safari 跨域数据共享有新方案?

各位大佬好:

项目有多个域名,会被用户随机访问,

想在浏览器上共享用户的登录状态。

参考一些项目,基本上用姿势都差不多:

https://github.com/zendesk/cross-storage

嵌入 iframe 然后使用 postMessage

而且在 safari 上有这样一段说明:

Notes on Safari 7+ (OSX, iOS) All cross-domain local storage access is disabled by default with Safari 7+. This is a result of the "Block cookies and other website data" privacy setting being set to "From third parties and advertisers". Any cross-storage client code will not crash, however, it will only have access to a sandboxed, isolated local storage instance. As such, none of the data previously set by other origins will be accessible. If an option, one could fall back to using root cookies for those user agents, or requesting the data from a server-side store.

也参考了这个讨论:

https://www.v2ex.com/t/520756

甚至特意还去翻了一下淘宝的代码,发现他们也是用的这个库:

https://www.taobao.com/wow/z/tbhome/default/kissy-search-suggest-iframe

但是 safari 下似乎也是行不通。

SO ,2022 年了,safari 除了

方案 A) 打开「 Prevent cross-site tracking 」

方案 B) 依次显式跳转到域名下写 cookie 或 storage

方案 C) iframe 挂载写 cookie(似乎此路不通)

还有别的黑科技吗?

感谢~

发表回复

您的电子邮箱地址不会被公开。