I am using facebook's PHP SDK to log user into my website. Now when I click on logout button, it successfully clears the session. When he again clicks on login with facebook button, he automatically logs into my website with the same facebook account he used before logging out instead of showing logging in page.
<?php
session_start();
/*
echo "before logout.</BR></BR>";
echo 'id: ' . $_SESSION['id']."</BR></BR>";
*/
require_once 'Facebook/autoload.php';
require_once 'Facebook/Facebook.php';
$config = array();
$config['appId'] = 'My Appid';
$config['secret'] = 'My Secret';
$config['fileUpload'] = false;
$fb = new Facebook\Facebook([
'app_id' => 'My Appid', // Replace {app-id} with your app id
'app_secret' => 'My Secret',
'default_graph_version' => 'v3.2',
]);
//$facebook = new Facebook($config);
//$token = $fb->getAccessToken();
//$accessToken = $fb->getAccessToken(); // Not working - Error showing - undefined method
//echo $_SESSION['fb_access_token']; - This contains some long access token
unset($_SESSION['id']);
//echo $accessToken;
/*
echo "after logout.</BR></BR>";
echo 'id : '. $_SESSION['id']."</BR></BR>";
*/
//$url = 'https://www.facebook.com/logout.php?next=https://rocketevent.in&access_token='.$_SESSION['fb_access_token']; - going to facebook page, not returning back
//echo $url;
session_destroy();
$fb->getLogoutUrl();
//header('Location: '.$url);
//header("Location: ../../index.php");
?>