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
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):
/**
* Hack for Safari cross-domain cookies. See:
* http://anantgarg.com/2010/02/18/cross-domain-cookies-in-safari/
*/
$(document).ready( function() {
var isSafari = (/Safari/.test(navigator.userAgent));
if (isSafari) {
var iframe = $( "" );
iframe.attr( "id", "cookieframe" );
iframe.attr( "name", "cookieframe" );
iframe.hide();
var form = $( "" );
form.attr( "id", "cookieform" );
form.attr( "target", "cookieframe" );
form.attr( "enctype", "application/x-www-form-urlencoded" );
form.attr( "action", "startsession.php" );
form.attr( "method", "post" );
$("body").append( iframe );
$("body").append( form );
form.submit();
}
} );
In startsession.php I'm just starting the session: