I have
def get_manager():
return stx.CookieManager()
cookie_manager = get_manager()
in my imported file
and I import in main_app
from sdgkit.direct_prompter import cookie_storer
cookie_manager = cookie_storer.cookie_manager
so the issue is
cookie_manager = get_manager()
is executed once, when the module is first imported, and its result (stx.CookieManager() — a Streamlit component) is stored as a module-level global object.
As Streamlit doesn’t re-import Python modules per user session.
That means every user is accessing the same cookie_manager instance.
Since it’s linked to the same frontend component under the hood, cookies can appear shared across users/sessions (even if the browser cookies are different).
Solution is that
# cookie_storer.py
import extra_streamlit_components as stx
def get_cookie_manager():
return stx.CookieManager()
and
# main.py
from sdgkit.direct_prompter import cookie_storer
cookie_manager = cookie_storer.get_cookie_manager()
Note: on the other hand, I failed set cookie, there is afterwards codes and reruns after set cookie with extra_streamlit_components