Facebook PHP SDK - will not logout properly

前端 未结 8 761
滥情空心
滥情空心 2021-02-09 17:21

I\'ve been searching for hours for the solution to this problem but can\'t find one that works for me. When i click \"Logout\" on my site the user information is still visible a

8条回答
  •  心在旅途
    2021-02-09 17:29

    Doing it with PHP SDK is really easy, the documentation is just really awfull. You do not need to redirect to Facebook. You just have to clear the session that the Facebook class sets, there is a function for that in the Facebook base class called destroySession(). Here I'm doing it on a get.

    require_once('libs/facebook.php');
    
    $facebook = new Facebook(array(
        'appId'  => '1121111110112',
        'secret' => 'bcfsaasaaaaaa2b7adsae3a4dd5'
    )); 
    
    if(isset($_GET['action']) && $_GET['action'] === 'logout'){
        $facebook->destroySession();
    }
    

    The $facebook->getLogoutUrl() logs the user out of Facebook.

提交回复
热议问题