0

I have a small dynamic facebook tab which uses Facebook PHP SDK. It has a fangate function and the script uses sessions to store the getRequest, so the fangate works on subpages in tab also.

It worked well, but now we moved the script to other hosting server with SSL and it looks like the sessions aren't stored any more on the new server.

Do anyone have an idea where can be the problem?

Here is the index.php script:

<?php
session_start();
require 'src/facebook.php';

// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
  'appId' => '419696674760950',
  'secret' => 'THE SECRET',
));

$user = $facebook->getUser();

if ($user) {
  try {
    $likes = $facebook->api("/me/likes/145577828869070");
    if( !empty($likes['data']) )
        echo "I like!";
    else
        echo "not a fan!";
  } catch (FacebookApiException $e) {
    error_log($e);
    $user = null;
  }
}

if ($user) {
  $logoutUrl = $facebook->getLogoutUrl();
} else {
  $loginUrl = $facebook->getLoginUrl(array(
    'scope' => 'user_likes'
  ));
}


$signed_request = $facebook->getSignedRequest();
$signedRequest = $facebook->getSignedRequest();
if(isset($signed_request)) $_SESSION['signedRequest'] = $signed_request;
else $signed_request = $_SESSION['signedRequest'];


$page_id = $signed_request["page"]["id"];
$page_admin = $signed_request["page"]["admin"];
$like_status = $signed_request["page"]["liked"];
$country = $signed_request["user"]["country"];
$locale = $signed_request["user"]["locale"];



include ("header.php");
if(!isset($_GET['page'])) $_GET['page']="";
switch($_GET['page']) {

case "1":
$_SESSION['signedRequest'];
// If a fan is on your page
if ($like_status) {
include('leftside.html'); include('informace.html');
} else {
// If a non-fan is on your page
include ("nonfan2.html");}
break;

case "2": include('reference.html'); break;
case "3": include('clanky.html'); ;break;

case "4":
$_SESSION['signedRequest'];
// If a fan is on your page
if ($like_status) {
include ("formular.html");
} else {
// If a non-fan is on your page
include ("nonfan.html");}
;break;

case "5": include('clanok1.html'); break;
case "6": include('clanok2.html'); break;
case "7": include('clanok3.html'); break;
case "8": include('clanok4.html'); break;

default:
$_SESSION['signedRequest'];
// If a fan is on your page
if ($like_status) {
include('leftside.html'); include('informace.html');
} else {
// If a non-fan is on your page
include ("nonfan2.html");}
}
include ("footer.html");
?>
complex857
  • 20,425
  • 6
  • 51
  • 54
  • What is the php.ini file's `session.save_path` set to? Does the php user have write access to that directory? – Kato Sep 25 '12 at 16:17
  • @Kato 's question is very relevent if you use session files. If you modified sessions to be stored on a database make sure those are updated to have proper database access. Also have you installed the SSL certificate in a proper manner? I trust you arent using something like fbssl.co? – Roopak Venkatakrishnan Sep 25 '12 at 16:20
  • I've removed the API secret from the code, If it was real (looked real) you should regenerate it. – complex857 Sep 25 '12 at 17:17
  • session.save_path on the new server is set to: 2;/www/tmp and on the old server is it set to /apachetmp/sessions5. – Matej Nuhlicek Sep 25 '12 at 23:21
  • I also tried other script using sessions on that new server and that works. Couldn't be there some amateur mistake in this script I provided? – Matej Nuhlicek Sep 25 '12 at 23:23
  • About the SSL certificate - the hosting company instaled it so I think it should be okay. Session in this script doesn't work even if it's opened via unsecured http:// protocol. – Matej Nuhlicek Sep 26 '12 at 13:53

0 Answers0