St.session_state not working when deployed to Digital Ocean Cloud

Hello there,

I’m currently deploying my streamlit app to Digital Ocean, and everything worked fine. I deployed it as a Docker image in their APP service.
The only thing that is breaking (and I do not seem to be the only one see here to have this issue). I’m not sure what is causing it. The app works 100% when I run it locally.
I included the session state that isn’t working in the code snippet below. If you need more code / the whole codebase please let me know.

if "logged_in" not in st.session_state:
    st.session_state.logged_in = False

# ---- STREAMLIT PAGE -----
# ---- LOGIN ----
login_signup_expander = st.expander("Login/Sign Up")
with login_signup_expander:
    r1_col1, r1_col2 = st.columns(2)
    with r1_col1:
        with st.form("Login"):
            email = st.text_input("Email", placeholder="")
            password = st.text_input("Password", placeholder="*******", type="password")
            submitted = st.form_submit_button("Login")
            if submitted:
                token = login(email, password)
                if token:
                    st.session_state.jwt_token = token
                    st.session_state.logged_in = True
                    st.success("You have successfully logged in")
                    st.error("Could not authenticate you, please try again or if you have no account sign up.")

The login function is here

def login(email, password):
    url = f"{config('API_URL')}/login"
    login_data = {"username": email, "password": password}
    request =, login_data)
    if request.status_code == 200:
        data = request.json()
        secret_token = data["access_token"]
        bearer_token = secret_token
        return bearer_token
        return False

So what is not working is that, every time I click on something that reloads the page (like changing a radio button) it reloads the page but also empties the session state. So it does not save that I’m logged in at all. Which is not ideal.

Thanks again for he help.