Cookies disappear after page reload

I’m developing a chat app using streamlit.
I managed to connect loging into the app with backend api.
I’m trying to keep access_token inside the cookies but they are lost after page reload causing user to be logged out. Is there a way to persist the cookies after a page reload?

This is how I access the cookiemanager:

def get_cookie_manager():
    """Get or create a cookie manager singleton"""
    if "cookie_manager" not in st.session_state:
        st.session_state.cookie_manager = stx.CookieManager(key=login_settings.cookie_key)
    return st.session_state.cookie_manager

This may cause the cookie manager to be destroyed when session is destroyed but if I don’t use it i get this error:

streamlit.errors.StreamlitDuplicateElementKey: There are multiple elements with the same key='rag_cookie_key'. To fix this, please make sure that the key argument is unique for each element you create.