Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting cross-domain cookies in Safari

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?

like image 283
Luca Matteis Avatar asked Jan 03 '09 04:01

Luca Matteis


People also ask

How do I allow cross domain cookies in Safari?

Open the Safari browser. From the menu bar, go to Safari > Preferences. In the preferences dialog, go to the Privacy tab and disable the Prevent cross-site tracking permission.

Can you set cross domain cookies?

There's no such thing as cross domain cookies. You could share a cookie between foo.example.com and bar.example.com but never between example.com and example2.com and that's for security reasons.

How do I turn off cross site tracking in Safari?

You can stop third-party content providers from tracking you across websites to advertise products and services. In the Safari app on your Mac, choose Safari > Preferences, then click Privacy. Select “Prevent cross-site tracking.”


1 Answers

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)

like image 196
Paolo Bergantino Avatar answered Sep 21 '22 04:09

Paolo Bergantino