I can’t seem to catch the access token as invalid even when i logged out of facebook.
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
echo "Name: " . $user_profile['name'];
} catch (FacebookApiException $e) {
// If the user is logged out, you can have a
// user ID even though the access token is invalid.
// In this case, we'll get an exception, so we'll
// just ask the user to login again here.
error_log($e);
$user = null;
}
}
I am still getting the user name back even when i am logout of facebook. So apparently the access token seems still valid. How can i fix this?
Or should i test my app only in FB enviroment in an iframe?
The access token does not depend on yours auth status on Facebook. Facebook PHP SDK, that you are using, stores access token in PHP session. So, you can just clean your session.