1

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.

4

3 に答える 3

1

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
}

Edited:: in your logout.php, try doing:

$facebook = new Facebook(array('appId' => 'your_id', 'secret' => 'your_secret'));
//destroy the session
$facebook->destroySession();

Hope that helps

于 2012-09-12T09:39:21.700 に答える
0

Remove the offline_access from scope-parameter of login URL of Facebook.

于 2012-09-12T09:39:03.527 に答える
0

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.

于 2012-09-12T09:41:52.917 に答える