How to avoid logging out a user after refreshing the browser?

Hi everyone,

I’m using this code from @PavloSydorenko to store the users credentials in a mongodb database and it works fine. Only one problem, when a user refreshes the browser, they get logged out !
Is there a way to avoid that, please ?

After some reasearch, I understand that maybe I need to use CookieManager from extra-streamlit-components but I really don’t know how to impelement that in @Pavlo’s code.

I’ll be more than happy if someone can show how to do it or give me an alternative/better approach.

Thank you so much for your help :wink:

Hey @nou7lh,

One way that you could keep someone logged in across browser refreshes is to add some type of unique token/string to the current URL using st.experimental_set_query_params – then, when the user refreshes the browser, you could retrieve the token using st.experimental_get_query_params to verify that they’ve already logged in. Not a perfect solution but probably the simplest way to implement this functionality.

1 Like

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