-
Notifications
You must be signed in to change notification settings - Fork 4.3k
session_state not preserved when using st.switch_page #11115
Copy link
Copy link
Open
Labels
feature:st.session_stateRelated to session state managementRelated to session state managementfeature:st.switch_pageRelated to `st.switch_page`Related to `st.switch_page`priority:P3Medium priorityMedium prioritystatus:confirmedBug has been confirmed by the Streamlit teamBug has been confirmed by the Streamlit teamtype:bugSomething isn't working as expectedSomething isn't working as expected
Metadata
Metadata
Assignees
Labels
feature:st.session_stateRelated to session state managementRelated to session state managementfeature:st.switch_pageRelated to `st.switch_page`Related to `st.switch_page`priority:P3Medium priorityMedium prioritystatus:confirmedBug has been confirmed by the Streamlit teamBug has been confirmed by the Streamlit teamtype:bugSomething isn't working as expectedSomething isn't working as expected
Type
Fields
Give feedbackNo fields configured for issues without a type.
Checklist
Summary
I encountered an issue while trying to pass data via session_state between the pages in my multi-page app using
st.switch_page.my_repository/
├── streamlit_app.py
├── page_1.py
├── page_2.py
session_state.unitis initialized through a checkbox in streamlit_app.py.session_state.unitis lost upon clickingst.switch_pageon page 2.Interestingly,
session_state.unitis preserved when navigating pages via the sidebar or usingst.page_linkon page 1.Reproducible Code Example
Steps To Reproduce
streamlit run streamlit_app.pyturn session_state.unitto TrueExpected Behavior
session_state.unitshould be preserved after clickingst.switch_pageCurrent Behavior
Switches to page 1 and produces following:
Is this a regression?
Debug info
Additional Information
No response