Loss of a session state variable after hiding a text input

I have the same problem actually. Searching the forum I found the following workaround: Using st.session_state and key together