Streamlit Session State
Learn how to use session state with Streamlit.
We'll cover the following
State variable
There are times when we want to preserve the state of variables between application runs. This doesn’t usually happen since Streamlit scripts are executed from top to bottom during each run. This means that any variable values are reset every time the script is run.
If we want certain variables to remain unchanged between the runs, we use st.session_state
. This is a way to store values a variable should have, similar to how dictionaries work with a key:value. This variable, which is the key, then updates the value as needed.
Get hands-on with 1400+ tech skills courses.