Reputation: 1322
Hello I am using latest facebook php sdk for my app. I am getting issue with its logout. here is my code for logout.
<?php
$logout = $facebook->getLogoutUrl(array(
'next' => 'https://www.thevoucherlink.com/logout.php'));
?>
And this is my logout.php:
<?php
session_start();
unset($_SESSION['fb_uid']);
session_destroy();
header('location:https://www.thevoucherlink.com/index.php?ref=logout');
?>
After log out user log outs from facebook. But not from my app.
$user_id=$facebook->getUser();
This function returns the user id after log out.
Please help me to solve it. Thanks in advance.
Upvotes: 1
Views: 1441
Reputation: 100175
Try removing FB cookie along with unsetting session, like:
session_start();
$fb_key = 'fbs_'."YOUR_FB_APP_ID";
setcookie($fb_key, '', time() - 3600, '', '/', '');
unset($_SESSION['fb_uid']);
session_destroy();
Then you can try doing try..catch block, something like:
$userId = $facebook->getUser();
try {
$myDetails = $facebook->api('/me');
//will return details if still loggedin
} catch (Exception $e) {
//user has already logged out
}
In your logout.php, try doing:
$facebook = new Facebook(array('appId' => 'your_id', 'secret' => 'your_secret'));
//destroy the session
$facebook->destroySession();
Upvotes: 1
Reputation: 3740
Remove the offline_access
from scope
-parameter of login URL of Facebook.
Upvotes: 0
Reputation: 9616
May be the log-out link is logging out the user from Facebook, not from your application.
You have to use $this->Auth->logout();
to logout the user from your application.
OR
Try to use integration of PHP SDK with Javascript SDK.
Upvotes: 0