Skip to main content

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 st_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/st-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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

st_cookies_manager-0.2.2.tar.gz (48.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

st_cookies_manager-0.2.2-py3-none-any.whl (64.9 MB view details)

Uploaded Python 3

File details

Details for the file st_cookies_manager-0.2.2.tar.gz.

File metadata

  • Download URL: st_cookies_manager-0.2.2.tar.gz
  • Upload date:
  • Size: 48.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.7.13 Windows/10

File hashes

Hashes for st_cookies_manager-0.2.2.tar.gz
Algorithm Hash digest
SHA256 aa42600f16e67119b09fa84a6ac9e3eecd4154e0b4970fc5ead4a3a5e5405028
MD5 ada3122774f886ce9fec72cbee7b87e5
BLAKE2b-256 d824afad2bcecc8579f504ebd7c87a0e1caad1e3dff8a8b8111fa7397a19a993

See more details on using hashes here.

File details

Details for the file st_cookies_manager-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for st_cookies_manager-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 78c2b3c4d6e1882a8b52cdda95948d0c88b823cb6d48ab44a2c363ef96447b41
MD5 3087cd9ffbf968c6b26ed5ab31af3313
BLAKE2b-256 912da8dd8ca95f92cd4761884ef1b24823d4cdda7d98104c5c286d3155b2cc76

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page