Access and change browser cookies from Streamlit scripts:
importstreamlitasstfromstreamlit_cookies_managerimportCookieManager# This should be on top of your scriptcookies=CookieManager()ifnotcookies.ready():# Wait for the component to load and send us current cookies.st.stop()st.write("Current cookies:",cookies)value=st.text_input("New value for a cookie")ifst.button("Change the cookie"):cookies['a-cookie']=value# This will get saved on next rerunifst.button("No really, change it now"):cookies.save()# Force saving the cookies now, without a rerun