1

I am working on a Facebook iframe app. I am using both the PHP SDK and the JS SDK. In my index file I call on the PHP SDK for some information about the user. This includes the getUser() function, which always works in the index.

I have a number of other PHP files, however, that I use to populate divs in the index when the user clicks on certain links. I am using the FB PHP SDK in each one of these files to ensure that the user is still logged into FB. That is, when these files are executed I call on the getUser() function to get the user's ID and determine if the person is still logged in. I inject the content of these PHP files into the divs in index via jQuery's load() function.

This works under FFox, Opera, IE, and Chrome just fine but under certain installations of Safari it does not. Specifically, I've had major issues with 5.1.5 (7534.55.3). When the PHP files get called by the jQuery load function under this version of Safari the getUser() function always seems to return 0 (zero). I'm assuming this has something to do with the session cookies? I really don't know and was hoping someone on here could shed some light on this for me. Thanks..

keybored
  • 5,194
  • 13
  • 45
  • 70
  • 1
    Could this other question help? http://stackoverflow.com/questions/10192142/missing-cookies-on-iframe-in-safari-5-1-5 – Shaun Baker May 22 '12 at 14:22
  • Oh my goodness thank you! I had no idea all that was going on with Safari. If you'w like to get the credit feel free to make an answer on this question. :) – keybored May 22 '12 at 18:32

2 Answers2

0

you can add this to your site:

<?php
$uid = $facebook->getUser();

if ($uid==0) {

    $params = array(
      'scope' => 'read_stream, friends_likes',
      'redirect_uri' => 'https://www.myapp.com/post_login_page'
    );

    $loginUrl = $facebook->getLoginUrl($params);
    echo '<a href="'.$loginUrl.'">You need first to Login</a>';
    exit();

} else {

     //Continue your site code

} 


?>
Julio Popócatl
  • 712
  • 8
  • 16
0

Not sure if this is an issue any more but it impacted my Safari FB app development for some time. Check out this SA answer to fix it, I pretty much followed it exactly and it worked. Missing cookies on iframe in safari 5.1.5

Community
  • 1
  • 1
keybored
  • 5,194
  • 13
  • 45
  • 70