dsam70528 2012-09-12 09:33
浏览 76
已采纳

注销后,Facebook php sdk返回用户ID

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.

  • 写回答

3条回答 默认 最新

  • dsjbest2014 2012-09-12 09:39
    关注

    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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法