Safari and php sessions not working in facebook iframe

前端 未结 3 1283
情深已故
情深已故 2021-02-04 17:04

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

3条回答
  •  孤城傲影
    2021-02-04 17:36

    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 = $( "