I have a facebook iframe facebook app. At the top of each page I run the authentication script from the php example included. For some reason however if I login to one facebook account, access my application, log out of facebook and into a new account when I visit the application I am still authenticated as the first user.
How come the session still exists? Why does the Facebook library not realise it is invalid?
please help.
Here is my authentication script that I include at the top of each page. It is almost identical to the example. The only change is that I have added a line to pass a GET parameter through the login url.
$uid = null; //facebook user id
require_once "facebook.php";
// Create our Application instance.
$facebook = new Facebook(array(
'appId' => $conf['fb']['appid'],
'secret' => $conf['fb']['secret'],
'cookie' => true,
));
if (is_numeric($_GET['user_id'])) {$user['id'] = $_GET['user_id']; $loginUrlParam = '?user_id='.$_GET['user_id'];}
//Facebook Authentication part
$session = $facebook->getSession();
$loginUrl = $facebook->getLoginUrl(
array(
'canvas' => 1,
'fbconnect' => 0,
'req_perms' => 'publish_stream',
'next' => $conf['dir']['app_url'].$loginUrlParam
)
);
$fbme = null;
if ($session) {
try {
$uid = $facebook->getUser();
$fbme = $facebook->api('/me');
} catch (FacebookApiException $e) {
echo "<script type='text/javascript'>top.location.href = '$loginUrl';</script>";
exit;
}
}
print_r($fbme);
Update:
Just found something very weird. I am able to be logged into facebook in two browsers. I know in the past if I logged into one from one from one browser it would log me out of the other. Is there a problem with facebook atm?