liveBook · Manning

St.logout

As explained in Build Python Web Apps with Streamlit

st.logout is a Streamlit API function that ends the current authenticated session and returns the user to the app's main page.

st.logout is Streamlit’s native authentication action for ending the current logged-in session and returning the user to the app’s main page. It fits alongside st.login and st.user in an authentication flow backed by an OpenID Connect identity provider. section 8.4.3

Add a log-out action

Place st.logout() behind a Log out control or page. With native authentication, the call ends the user’s session and returns them to the app’s main page. A custom session-state flow instead clears the stored user and logged-in flag, then calls st.rerun() so the navigation changes immediately. section 8.4.3

How Build Python Web Apps with Streamlit covers it

How deep it goes
Defines the logout behavior and contrasts it with session-state clearing, but does not detail the underlying authentication protocol.
Examples
Uses a logout page, navigation options, cleared session-state values, and st.rerun() as concrete logout examples.
What it assumes
Assumes familiarity with Streamlit navigation and authentication concepts, while identifying identity-provider setup through OpenID Connect.
What you can do after
Operate a Streamlit authentication flow by ending a user session with st.logout().
How it connects
Connects logout with st.login, st.user, OpenID Connect, session state, navigation, and reruns.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build Python Web Apps with Streamlit. The section links point to the parts of the book it draws on.