Access and save cookies from Streamlit
Project description
Streamlit Cookies Manager
This is repo fork: https://github.com/ktosiek/streamlit-cookies-manager
Access and change browser cookies from Streamlit scripts:
import os
import streamlit as st
from st_cookie_manager import EncryptedCookieManager
# This should be on top of your script
cookies = EncryptedCookieManager(
# This prefix will get added to all your cookie names.
# This way you can run your app on Streamlit Cloud without cookie name clashes with other apps.
prefix="ktosiek/streamlit-cookies-manager/",
# You should really setup a long COOKIES_PASSWORD secret if you're running on Streamlit Cloud.
password=os.environ.get("COOKIES_PASSWORD", "My secret password"),
)
if not cookies.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")
if st.button("Change the cookie"):
cookies['a-cookie'] = value # This will get saved on next rerun
if st.button("No really, change it now"):
cookies.save() # Force saving the cookies now, without a rerun
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
st_cookie_manager-0.2.0.tar.gz
(679.8 kB
view hashes)
Built Distribution
Close
Hashes for st_cookie_manager-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d89a668245c54a7ba7c7b1a524141c65f05cbd621df04a3d47bacc09caeaa449 |
|
MD5 | f80abc6532b9c4aaf9f337338755cad7 |
|
BLAKE2b-256 | 103d312cc29044afec91f37d8ec3f8fd428571e84a5395d3fcc13b871d0e5d7f |