在Safari中设置跨域Cookie [英] Setting cross-domain cookies in Safari

查看:3290
本文介绍了在Safari中设置跨域Cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Evernote 的书签可以执行此操作,因此最常用的答案不会回答这个问题



我必须调用域A.com(它设置Cookie的http )from domain B.com。
我在域B.com上所做的一切都是(javascript):

  var head = document.getElementsByTagName )[0]; 
var script = document.createElement(script);
script.src =A.com/setCookie?cache=1231213123;
head.appendChild(script);

这会在每个已测试的浏览器上设置A.com上的Cookie,但Safari除外。
令人惊讶的是,这在IE6中工作,甚至没有P3P头。



有什么办法让这个工作在Safari吗?

解决方案

Safari开发人员常见问题


Safari附带保守Cookie策略,其将cookie写入限制到仅由用户选择(导航到)的页面。此默认保守策略可能会混淆尝试写入Cookie并失败的基于框架的网站。


我没有办法解决这个问题。



如果值得使用,Chrome不会设定Cookie,如果您使用< script >方法,但如果您使用相同的来源拥有隐藏的< img >,Chrome除了其他浏览器(除了Safari) >

Evernote's bookmarklet is able to do this, therefore the most upvoted answer does not answer this even though the bounty will go to it (in a non-productive manner).

I have to call domain A.com (which sets the cookies with http) from domain B.com. All I do on domain B.com is (javascript):

var head = document.getElementsByTagName("head")[0];
var script = document.createElement("script");
script.src = "A.com/setCookie?cache=1231213123";
head.appendChild(script);

This sets the cookie on A.com on every browser I've tested, except Safari. Amazingly this works in IE6, even without the P3P headers.

Is there any way to make this work in Safari?

解决方案

From the Safari Developer FAQ:

Safari ships with a conservative cookie policy which limits cookie writes to only the pages chosen ("navigated to") by the user. This default conservative policy may confuse frame based sites that attempt to write cookies and fail.

I have found no way to get around this.

If it's worth anything, Chrome doesn't set the cookies either if you use the <script> appending method, but if you have a hidden <img> with the same source, Chrome works in addition to the rest of the browsers (except, again, Safari)

这篇关于在Safari中设置跨域Cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆