Access and save cookies from Streamlit
Project description
Streamlit Cookies Manager
Access and change browser cookies from Streamlit scripts:
import os
import streamlit as st
from streamlit_cookies_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
Built Distribution
Close
Hashes for streamlit_cookies_manager_hotpatched-0.2.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 860d02ca22b5e6400ccf52f6f488359fc49412ad0abe5925cc378b15cecc9b7d |
|
MD5 | d985123028a057508219aa32fbc609b9 |
|
BLAKE2b-256 | 8458391e83435e46448e52e124c739670ab7e52974a610a9d57fc77ccace6859 |
Close
Hashes for streamlit_cookies_manager_hotpatched-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1598f12ed8cc8c6d37acafbe408cc00b60a64ea1c12ce96a60382c7eed068187 |
|
MD5 | 5e24eba8f9f0d48bb7e06ddfbd3b92eb |
|
BLAKE2b-256 | 21421f536c5cb9e720f0374b8d4d3c9ae9c775fa81b80fda447434c0564e0716 |