Multi-user issue, session_state not unique for each user

Hello everyone,

I create this topic because I ask the question in other topic but I think it is better to create a new one.

My issue is:
The fact that st.session_state is global for the deployed application and not unique for each user.

Maybe it is my understanding that is not correct but I feel that it is a big issue if we have multiple user connect to the app at the same time.

Demonstration of the issue:
simple demonstration
Below is the code of the app. I should show always 1 when you open the app as a new user but it is not the case and my only explanation is that each users share the same st.session_state.

import streamlit as st

if 'proof' not in st.session_state:
reset_button=st.button("Reset session_state")
if reset_button:

I find it a issue because in more complicated application we need to use st.session_state to store information, parameters, graph,… but with this issue it means that if I have multiple user they will keep rewrite and erase the st.session_state of other user who are on the page at the same time. Another example of this issue is with my other application if you go there and click on the “Prediction” page in the sidebar you will see the graph of the last data I put inside, you should not see that because you didn’t upload any data.

I don’t know if it is a real issue or just how streamlit is supposed to work but please explain to me how can I have multiple user at the same time in the app.

I found the issue and the solution of it.
The problem in my code come from the reset button:

if reset_button:

When I click on it, it destroy the st.session_state and make it global for every user that connect after that.
To solve that I replace it with st.session_state.clear() as suggested here by Goyo.
I think it is a good idea to let this topic here in case new people do the same mistake as me.

1 Like

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

Thanks @Christophe for sharing this with the community!