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 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


Download files

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

Source Distribution

streamlit-cookies-manager-0.2.0.tar.gz (680.1 kB view details)

Uploaded Source

Built Distribution

streamlit_cookies_manager-0.2.0-py3-none-any.whl (691.0 kB view details)

Uploaded Python 3

File details

Details for the file streamlit-cookies-manager-0.2.0.tar.gz.

File metadata

  • Download URL: streamlit-cookies-manager-0.2.0.tar.gz
  • Upload date:
  • Size: 680.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.9.7 Linux/5.13.0-23-generic

File hashes

Hashes for streamlit-cookies-manager-0.2.0.tar.gz
Algorithm Hash digest
SHA256 498531778bd4a63267364e8986b3774319d3ba2f4ba65a92357196723966e4d4
MD5 c883cb43ecde0396809b316eb9dd1c30
BLAKE2b-256 a815d016f1b2e1c547fecf7782dac3860d2aad4e22b4c1664d78bb2a873163ef

See more details on using hashes here.

File details

Details for the file streamlit_cookies_manager-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_cookies_manager-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 12503dc3367dfc2a780cb9e4a81ad791737806a7b9d1c25a006386e32aabe956
MD5 3c87b333d821e94df5cb266f966dfa66
BLAKE2b-256 6160d4aefff016f9fe48d10c59b2e52ae823444525f973e7948821c9eefb4217

See more details on using hashes here.

Supported by

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