문제

How to logout the user from our site when they logged out from Facebook?

Currently, when user logout, the fb_*_user_id sessions is still returns users ID,

I tried to call $fb->api('/me'), and still, all users data is still there..

I'm really sorry for asking this question because I'm quite sure it's being ask all the time, But seriously, FB API giving me a headache. I've tried some of the code from solved question, but it doesn't seems to work, and most of them are outdated.

I'm using PHP SDK and hosting on localhost.

Thanks

$facebook = new Facebook($config);

var_dump($facebook);
echo 'UID : '.$facebook->getUser();


if($facebook->getUser()==0){
    echo 'Not login!';
    echo "<br><a href='".$facebook->getLoginUrl()."'>Login</a><br>";

}else{
    $fbme = $facebook->api('/me');
    echo 'Welcome, "'.$fbme['name'].'"!';   
    echo "<br><a href='".$facebook->getLogoutUrl()."'>Logout</a><br>";
}
도움이 되었습니까?

해결책

Try adding a listener for when the user logs out;

FB.subscribe('auth.logout', function(response){
    // Do something to let your program know that the user is now logged out.
});

Add your own facebook logout to your site with FB.logout(). This should clear your website's fb session as well as log them out of facebook.com.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top