I am using Facebook php-sdk in my iframe facebook app to get user login status. Right after I sign out using facebook Account > Log out link, the session is not destroyed yet. I must wait a few minutes before old session expires, then my app will again get the correct login status.
I expect the facebook to kill itself and the session when user signs out. How do I manually kill the session?
Here is my code:
$initParams = array( 'appId' => $conf['app_id'], 'secret' => $conf['secret_api_key'], 'cookie' => TRUE, ); $fb = new Facebook($initParams); $fb->getSession(); // will return a session object eventhough user signed out! SOLVED:
calling $fb->api('/me') will destroy the session if user has previously logged out. I've changed my code as following:
if ($session) { try { $fbuid = $fb->getUser(); $me = $fb->api('/me'); } catch(FacebookApiException $e){} } If the API call is unsuccessful, $session will be set to NULL. Very weird behavior, I don't explain everything that is going on here but it solved my problem of having residual session object not being updated via getSession() method.