I'm having a problem to make my facebook app working on Safari.
The issue is related to the PHP session variables.
I am aware that Safari has a problem dealing with cross domain sessions (inside an iframe) and i found around 2 types of solutions:
- Setting the p3p header: i've tried many p3p header found around but no one of them worked [for example:
header('P3P: CP="NOI ADM DEV COM NAV OUR STP"');
]. - Sending a post to the iframe, using javascript. This creates interaction and sessions should work. But the fact is that i do not control the iframe container, as that is facebook.
Does anyone know an alternative solution?
Thanks!
EDIT: Confirmed, this workaround no longer works on Safari 5.1 on Mac. Discussed here: Safari 3rd party cookie iframe trick no longer working?
I don't know what's your use case but in our app we have a welcome screen with an 'Allow Access' button that opens the permissions dialog. When the user clicks 'Allow Access' I use that to open a new window that sets the session and closes immediately (this was proposed in the question linked above). After the user has allowed access you can just reload the page? In our case this is not needed since all communication to the server is with ajax.
I'm using the second solution and have no problem with it, here's my code (using jQuery):
In startsession.php I'm just starting the session:
I am late to this but it may well help someone else looking up this problem.
The only method I could make work was to detect safari from inside my iframe and redirect to another page momentarily where I could set my session cookie - then redirect back.
Then from setcookie.php
its a bit lame but does work and doesn't interfere with the other browsers. The other method is to use a popup window although my safari had this blocked by default.
by far not the nicest solution but you don't need any extra Pages put the Solution on the very first position on your page so you only see some white Flickering.
send your referring url to the page where you actually do your stuff. nothing additional needed. then reffer back to the page you have been in the first place.