Facebook iFrame canvas app

I have been working on a problem for the past one and a half days and still want to find a solution.

When you visit my game on facebook (which is on facebook iFrame), php sessions do not work. This is for IE and Safari. Chrome is working fine.

I already read all the stack messages about this issue, which seems to be related to the protection of third-party cookies and requires interaction with iFrame. A workaround came up by first making javascript messages about some data forms in the iFrame, but this seems to have been fixed in recent versions of browsers quite recently, as it no longer works.

I even tried to embed a start page that would require them to first click the link (in the iFrame) to load another page that would then create a session. But even THAT does not work.

I am also having problems loading new pages in an iFrame using javascript, which seems to always trigger an infinite refresh cycle.

And no, P3P headers DO NOT solve the problem.

Does anyone have a solution to this problem? I can't be the only one with it, considering how many facebook apps exist!

+5
source share
2 answers

, , " cookie" . PHP URI, :

ini_set('session.use_trans_sid', true);

URL- iframe Facebook, SID .

+5

IE P3P. - :

<?php header('P3P: CP="CAO PSA OUR"'); ?>

Safari cookie . , , - "" cookie. - :

<script type="text/javascript">
    function safariFix(){
        if (navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1){
            window.open('https://yourdomainname.com/safari.php', 'Safari Fix','width=100,height=100');
        }
    }
</script>

safari.php :

<?php 
setcookie("safari_test", "1");
?>
<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Safari Fix</title>
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> 
    </head>
    <script type="text/javascript">
    $(document).ready(function(){
        window.close();
    });
    </script>
    <body>
        Since Safari does not accept third-party cookies by default, we are forced to open this window.
        This window will automatically close once we have set the cookies.
    </body>
</html>

: , Safari " ". - , ;)

+3

All Articles