13

I followed the example: http://arunranga.com/examples/access-control/credentialedRequest.html

from this page: http://arunranga.com/examples/access-control/

The example work in Firefox, but not Safari, anyone have tried in implementing CORS cross domain cookie handling, and being success in Safari?

Thanks.

Howard
  • 19,215
  • 35
  • 112
  • 184
  • ran into the same issue, thanks for posting it! – KARASZI István Jun 30 '11 at 08:55
  • Possible duplicate of [Setting cross-domain cookies in Safari](https://stackoverflow.com/questions/408582/setting-cross-domain-cookies-in-safari) – Dom Jun 08 '18 at 11:31
  • It is not a duplicate as the other answer talks about setting in script and this one about the request/server setting the cookie – Tofandel Sep 24 '20 at 01:39

3 Answers3

14

Safari also blocks cookies from sites that haven't been visited directly. You can see in the security settings. It's default setting is Accept cookies: "Only from sites I visit".

This will help get you started. Setting cross-domain cookies in Safari

I have jsonp working in safari using methods in the above link. So assumed that the cookie would work in the CORS context, but at this stage it doesn't seem to be working. Also, changing the security setting seems to have no effect.

Safari might demand a stricter set of headers to be returned?

Community
  • 1
  • 1
23inhouse
  • 1,889
  • 19
  • 18
9

This sounds like a Safari bug. I just verified that cross-domain cookies aren't being set in Safari. Cross-domain cookies are working in Chrome, so this may be fixed in WebKit and the latest hasn't made it to Safari yet. I haven't seen a Safari or WebKit bug report about this.

monsur
  • 45,581
  • 16
  • 101
  • 95
0

I encountered this with API/UI apps on different subdomains of Heroku, like my-api.herokuapp.com and my-ui.herokuapp.com, session cookie was set for my-api.herokuapp.com. Even visiting my-api.herokuapp.com didn't seem to help Safari in this case with its default 'Only from sites I visit' policy @23inhouse mentioned: http://content.screencast.com/users/artemv/folders/Jing/media/4dfc08d7-0e9c-483f-a272-bbe91549ea95/00000759.png.

However, Safari worked just fine when we assigned a custom domain to these apps and it became my-api.mydomain.com and my-ui.mydomain.com - so it looks like Safari has particularly low trust to popular hosters' subdomains. No direct visit to my-api.mydomain.com was needed in this case.

Artem Vasiliev
  • 2,063
  • 1
  • 24
  • 21