Unable to remember state after experimental_rerun()

Your description is a little too abstract for me to be certain, but I would guess you are running in to the widget cleanup process or the non-statefulness of buttons.

For buttons, they will return true only on the page load resulting from their click and then go back to false. Therefore, there is a problem if you put anything interactive conditioned on a button or you put any rendering commands you want to stay visible while the user continues to interact elsewhere.

For widget keys, when a widget is not rendered on the page whether conditionally or by navigating to another page, the key associated to the widget will be removed from session state. Therefore, if you are wanting data to persist beyond the destruction of a widget, you need to copy its data to a different key (or do a more hacky solution to interrupt the cleanup process).

Say that widget keys are prefixed with an underscore as a convention:

import streamlit as st

def keeper(key):
    #Save data from the widget key to a persistent key
    st.session_state[key] = st.session_state['_'+key]

def retriever(key):
    #Check for persistent key and populate widge key for multipage statefulness
    if key in st.session_state:
        st.session_state['_'+key] = st.session_state[key]

#If you want to declare any initial values, initialize the persistent keys
#directly instead of using the widget's value keyword. This avoids a warning.
if 'my_key' not in st.session_state:
    st.session_state.my_key = 55.5

retriever('my_key')
st.number_input('Example', key='_my_key', on_change=keeper, args=['my_key'])


key = st.selectbox('Widget',['A','B','C','D'])

retriever(key)
st.text_input(key, key='_'+key, on_change=keeper, args=[key])