Tip
Learn more in User authentication and information.
st.logout
Logout the current user.
This command removes the user's information from st.user, deletes their identity cookie, and redirects them to perform a proper logout from the OAuth provider (if available) before returning to your app's home page. This creates a new session.
If the user has multiple sessions open in the same browser, st.user will not be cleared in any other session. st.user only reads from the identity cookie at the start of a session. After a session is running, you must call st.login() or st.logout() within that session to update st.user.
Note
If the OAuth provider supports OIDC end_session_endpoint in their server metadata, the user will be logged out from the identity provider as well. If not available, only local logout is performed.
| Function signature[source] | |
|---|---|
st.logout() |
Example
.streamlit/secrets.toml:
Your app code:
Still have questions?
Our forums are full of helpful information and Streamlit experts.
