signed_request disappears on safari?

I'm making simple page tab for facebook, but it seems to have a problem only on Safari on Mac. With Safari on Windows, there's no problem. The page is made in 3 types - fangate (when the user hasn't liked the page), main page (when liked) and a link to 3rd page. When I enter the page tab, it shows the fangate. Then I "like" the page and shows the main page, but when I click the link to the 3rd page it shows me the fangate. I think it's loosing the signed_request session. Is there a way to pass the signed_request on every page without using sessions?


I'm not sure if you're using the PHP SDK. If so, this code may work for you. If a signed request is found (as it would be on the main page after you like the page), store it in a session. For each page after, you check for the session version of the signed request. This code must go on each page (with include or however you choose).

<? php
//get signed request
$signedRequest = $facebook - > getSignedRequest();

//check if inital vars can be used or use session loaded vars
if (isset($signedRequest)) {
    echo '<!-- INITIAL LOAD -->';
    $_SESSION['signedRequest'] = $signedRequest;
} else {
    echo '<!-- STORED SESSION -->';
    $signedRequest = $_SESSION['signedRequest'];

//check like status
$liked = (!$signedRequest['page']['liked'] ? false : true);

//check if page is liked
if ($liked === false) {
    //********************* NOT LIKED, SHOW LIKE GATE *********************
} else {
    //********************* LIKED, SHOW PAGE CONTENT *********************

Sorry for late answer. Yes, I'm using PHP SDK and the exact same code you wrote there (check for signedRequest and if there's one -> store it in session, otherwise -> get it from session). But it seems that Safari is loosing the session parameters. The two ways I figured out as working are these:

  1. Target all links to _top and add to them the parameters, so every time user changes the page, it reloads the whole page (not only in the iframe) and passes the variables trough app_data.

  2. Add signedRequest to every link, so whenever the user switches page, there's signedRequest in the url. This method actually doesn't refresh the whole page, because it's sending the parameters in the iframe website, so it's a bit better from the first one.

Both methods require to pass data in links, which I don't want to do, because I'll have to change every link in my app. I haven't tried to store the signedRequest in cookie yet.

But if there's ANY other way, that doesn't require major link changing or storing data in cookies, I'll be glad to hear them.

Need Your Help

PHPMailer not working in my server

php email ubuntu phpmailer sendmail

I built a droplet with Ubuntu with DigitalOcean and I'm trying to configure it to send emails with SMTP.

How to vertically and horizontally center an img in a fullscreen div?

html css image vertical-alignment

The following code shows a logo and it's background. I can't get the logo centered vertically. Is it because the background div has no height defined? How can I get the background to be always 100%...