I've got 2 tabs open in Firefox, one is my website and the other is Facebook. Without the app authorised I get a login link, I click this which I am then prompted to auth the app which I do so.
I've now got on screen the logout URL provided by getLogoutUrl() - when I click this it redirects back to my site which I am happy with however it is still classing me as logged in. If I refresh the other tab with Facebook on I am now logged out. It seems there's some hangover on the session??
<?php
require_once("fb/facebook.php");
$config = array();
$config['appId'] = '...';
$config['secret'] = '...';
$config['fileUpload'] = false; // optional
$facebook = new Facebook($config);
$user_id = $facebook->getUser();
if($user_id) {
//Got an ID - Facebook says we're logged in
try {
$user_profile = $facebook->api('/me','GET');
echo "<img src=\"http://graph.facebook.com/".$user_profile['username']."/picture\"><a href=\"".$user_profile['link']."\">" . $user_profile['name']."</a>";
$logout_url = $facebook->getLogoutUrl();
echo "<a href=\"" . $logout_url . "\">Logout</a><br><br><br>";
}
catch(FacebookApiException $e) {
$login_url = $facebook->getLoginUrl();
echo 'Please <a href="' . $login_url . '">login.</a>';
error_log($e->getType());
error_log($e->getMessage());
}
}
else {
// Not logged in - give URL to login
$login_url = $facebook->getLoginUrl();
echo 'Please <a href="' . $login_url . '">login.</a>';
}
?>