Logout
Updated: May 21, 2021
The method
FB.logout() logs the user out of your site and, in some cases, Facebook.
Consider the 3 scenarios below:
- A person logs into Facebook, then logs into your app. Upon logging out from your app, the person is still logged into Facebook.
-
A person logs into your app and into Facebook as part of your app's login flow. Upon logging out from your app, the user is also logged out of Facebook.
(However, if browser cookies are disabled, for example, Chrome incognito mode, the person may not be logged out of Facebook.) - A person logs into another app and into Facebook as part of the other app's login flow, then logs into your app. Upon logging out from either app, the user is logged out of Facebook.
Example
FB.logout(function(response) {
// user is now logged out
});
Best Practices
FB.logout will log the user out of your site and, in some cases, Facebook (see the cases above). You will need to have a valid access token for the user in order to call the function.
Calling
FB.logout will also invalidate the access token that you have for the user, unless you have extended the access token.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
cb | Function | yes | The callback function. |