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.0b0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5fe4dd320de3bd37439f82b8c194c350ad6d45cea0c2ec20d9e8eac1dd3a9d63 |
|
MD5 | 3ab1aa9ed20e79235499aeda2e28c3b3 |
|
BLAKE2b-256 | 05c72f80df8c3af6c2b770c032f38b14884a29cd1d9021a273a5b37ec4911a1b |
Close
Hashes for streamlit_cookies_manager_hotpatched-0.2.0b0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 01410deb538c121ceb2e9ee8678c5405a4e14726e2613437df3baf9ce8018f14 |
|
MD5 | 9fc845b09abd7eb93d01510dc2044a8c |
|
BLAKE2b-256 | 607e90f83bc740a616a2d2961cf4a9d6b28213ae70f6cfdb056298a973b26e82 |