The important thing to understand is that widget information is deleted whenever a widget is not continuously rendered. This can happen by changing pages or even by conditionally not rendering the widget on the same page.
There are two workarounds to preserve widget values across pages, both require using a key with your widget:
- Use a dummy-key to separate a value you want to keep in session state persistently from a value Streamlit associates to a widget (and automatically deletes).
- Recommit keys to session state at the top of every page.