Open uprg opened 6 months ago
3.8.10
Ubuntu 20.04.6 LTS (focal)
1.32.1
0.1.71
The key and value of cookie set by cookie manager is not getting set in st.session_state but is set in browser cookies
https://github.com/Mohamed-512/Extra-Streamlit-Components/assets/56631384/04f665dc-2514-458d-9c6c-0c6c245116f3
Install the above dependencies and run the below code
import extra_streamlit_components as stx import streamlit as st st.write(st.session_state) if "is_logged_in" not in st.session_state: st.session_state["is_logged_in"] = False cookie_manager = stx.CookieManager() def check(): # st.write("func called") # st.write(cookie_manager) user_cookie = cookie_manager.get(cookie="user") # st.write(user_cookie) if user_cookie: st.session_state["is_logged_in"] = True else: st.session_state["is_logged_in"] = False check() if st.session_state["is_logged_in"] == False: name = st.text_input(label="cookie name") value = st.text_input(label="cookie value") set = st.button(label="set cookie") if set: cookie_manager.set(cookie=name, val=value) #st.session_state["is_logged_in"] = True if st.session_state["is_logged_in"] == True: get = st.button(label="get cookie") delete = st.button(label="delete cookie") if get: cookie_manager.get(cookie="user") if delete: cookie_manager.delete(cookie="user")
The key and value should be set in st.session_state also with the browser cookie storage
I don't think this is an expected behaviour.
Python version
3.8.10
OS version
Ubuntu 20.04.6 LTS (focal)
streamlit version
1.32.1
extra_streamlit_components version
0.1.71
Describe the bug
The key and value of cookie set by cookie manager is not getting set in st.session_state but is set in browser cookies
https://github.com/Mohamed-512/Extra-Streamlit-Components/assets/56631384/04f665dc-2514-458d-9c6c-0c6c245116f3
To Reproduce
Install the above dependencies and run the below code
Expected behavior
The key and value should be set in st.session_state also with the browser cookie storage