<a id="disconnect-and-logging-out"></a>

# Disconnect and Logging Out

It’s a common misconception that the `disconnect` action is the same as
logging the user out, but this is not the case.

`Disconnect` is the way that your users can ask your project to “forget about
my account”. This implies removing the `UserSocialAuth` instance that was
created, this also implies that the user won’t be able to login back into your
site with the social account. Instead the action will be a signup, a new user
instance will be created, not related to the previous one.

Logging out is just a way to say “forget my current session”, and usually
implies removing cookies, invalidating a session hash, etc. The many frameworks
have their own ways to logout an account (Django has `django.contrib.auth.logout`),
`flask-login` has it’s own way too with [logout_user()](https://github.com/maxcountryman/flask-login/blob/a96de342eae560deec008a02179f593c3799b3ba/flask_login.py#L718-L739).

Some providers also maintain their own sign-in session. Clear the local session
and redirect the browser to the provider’s logout endpoint when provider logout
is required. Azure AD B2C provides a URL helper and a Django example; see
[B2C provider logout](backends/azuread.html.md#azure-b2c-logout). Provider logout does not remove the social account
association.

Since disconnecting a social account means that the user won’t be able to log
back in with that social provider into the same user, python-social-auth will
check that the user account is in a valid state for disconnection (it has at
least one more social account associated, or a password, etc). This behavior
can be overridden by changing the [Disconnection Pipeline](pipeline.html#disconnection-pipeline).
