I am trying to implement the Facebook Login and Logout in my website. I am using the Facebook PHP SDK.
The code i am using is as follows :
$facebook = new Facebook(array('appId' => APP_ID, 'secret' => APP_SECRET )); $param = array(); $param["scope"] = array("email","offline_access","publish_stream"); $loginUrl = $facebook->getLoginUrl($param);
$logoutUrl = $facebook->getLogoutUrl();
The problem is logout url is not being able to logout the facebook user.
When i remove the "offline_access" from the scope parameters the logout Url is working fine.
I have also implemented the above scope in the example.php file in the PHP SDK and the result was the same.
Can anyone provide any help.
I found out my problem. After logging in from Facebook I called the function
$facebook->destroySession(); and after that, called the function
Because of the
destroySession() function the
access_token returned from Facebook got lost and my logout URL generated from the
getLogoutUrl() function could not log out the user from Facebook.
After removing the
destroySession() function my code is working fine.