Session_state get reset when the user refreshes the browser

Hello everyone,
I’m encountering issues with maintaining the session state. I have a MSAL login page where I log in and store the token in the session state. When I navigate to another page, I can retrieve the token from the session state to authenticate the screens. However, the problem arises when I refresh the browser: the session state resets, and even the key gets deleted. This is the error I encounter:

That’s the intended functionality since, when the user refreshes, they are creating a new session. Maybe Caching works better for you:

or using cookies

Is there any workaround or reference for implementing the cookie management in streamlit

There are several components, for example: GitHub - mkhorasani/Streamlit-Authenticator: A secure authentication module to validate user credentials in a Streamlit application.

I personally use this one because it fits our needs better: GitHub - ktosiek/streamlit-cookies-manager: Access and change cookies from your Streamlit script

1 Like

Thanks for the helping me out :innocent:

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.