Issue with the App-don't know how to add session state to the App

Summary

I team, I have an app that has two functions, the strong textfirst function is to display the menu option, and once the user inputs the details to log in to the database, then the second function appears displaying the table selection. However, when the user selects the table from the drop-down. The table selection option is disappearing

Steps to reproduce

Code snippet:

def menu():
      with     st.form(key="my_form"):
             global username
             username = st.text_input("Username:")
             global password
             password = st.text_input("Password:")
             global db_Host
             db_Host = st.text_input("Database Host:")
             global db_Name
             db_Name = st.text_input("Database Name:")
             global db_port
             db_Port = st.text_input("Database Port:")
             global submit
             global conn
             conn=None
             submit = st.form_submit_button("Connect")
def table_selection:
     if submit:
        .
        .
       .
    option = st.selectbox('Select table name', df,index=0,key='option')

If applicable, please provide the steps we should take to reproduce the error or specified behavior.

Expected behavior:
Once the table is selected from the drop-down, the option should show the new table selection

Explain what you expect to happen when you run the code above.

Actual behavior:

once the user is selecting the table from the drop-down menu, the drop-down menu is disappearing. I don’t know how to add session state to my code

Debug info

  • Streamlit version: (get it with $ streamlit version)
  • Python version: (get it with $ python --version)
  • Using Conda? PipEnv? PyEnv? Pex?
  • OS version:
  • Browser version:

Requirements file

Using Conda? PipEnv? PyEnv? Pex? Share the contents of your requirements file here.
Not sure what a requirements file is? Check out this doc and add a requirements file to your app.

Links

  • Link to your GitHub repo:
  • Link to your deployed app:

Additional information

If needed, add any other context about the problem here.

Hey @OmerZ11,

Have you checked out this doc and watched the video on session state?

To implement session state, you would just create a key and value for whatever value you want to keep track of, e.g.

st.session_state.selected_table = 'table2'     # Attribute API
st.session_state['selected_table'] = 'table2'  # Dictionary like API