Hi guys, Iām new to streamlit but very familiar with python.
I have a streamlit app that has a login page and the main app.
if login_page():
intro()
profile_state = create_profile_state(state_obj=st.session_state)
main_app(
profile_state=profile_state,
username=st.session_state["username"],
preferred_name=st.session_state["preferred_name"]
)
Here, login_page() returns True or False based on the credentials entered by checking secrets.toml file in the repo. It clears the page once login is True, and initiates the flow of the app.
intro() simply writes static text on the page.
create_profile_state() initiates st.session_state with required keys
main_app() takes the username from st.session_state and loads a profile matching the username from a local json file in the repo.
main_app() displays the profile_state and shows a dropdown to update the information in the state.
Once you click on the dropdown to Update Information, you see a text input box pre-filled with existing information, and a Update button at the end of the dropdown.
When I click update, the main_app() crashes since it doesnāt remember a st.session_state[āusernameā] from the login_page()
Update pretty much takes the new input from the dropdown and writes it to the local json file based on the username given. experimental_rerun() is used after this to reload the page with the new information. But main_app() crashes because it doesnāt have a āusernameā in st.session_state.
Please help. I donāt understand caching and having issues with states management clearly.