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.0rc0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ad1921e9f055579165865bb68ded8eedae1d582ef06c89471045fded5e12219 |
|
MD5 | 3a31c61901ffb4cc4907dc7c293a4a0b |
|
BLAKE2b-256 | 7c53c0d5f45c2eb23ba339e49afd21b0ee682a6a9cb426a5957841856d525cca |
Close
Hashes for streamlit_cookies_manager_hotpatched-0.2.0rc0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2fab16eeecc49487a7a48c34ee59497a428454848e6be8242a372cc2b6ab6e2f |
|
MD5 | ac8db45d5ffcd78bc4c56d38d6c7821c |
|
BLAKE2b-256 | 1a746fd50876e2830094816a6cea17891b83d600c7eaa358682e249ba852b2c2 |