Skip to main content

Access and save cookies from Streamlit

Project description

Streamlit Cookies Manager Extended

Extended version of Streamlit Cookies Manager. Support latest python and streamlit versions.

Access and change browser cookies from Streamlit scripts:

import os
import streamlit as st
from streamlit_cookies_manager_ext 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="streamlit-cookies-manager-ext/",
    # 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_ext-0.1.0.tar.gz (52.0 MB view details)

Uploaded Source

Built Distribution

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

streamlit_cookies_manager_ext-0.1.0-py3-none-any.whl (70.6 MB view details)

Uploaded Python 3

File details

Details for the file streamlit_cookies_manager_ext-0.1.0.tar.gz.

File metadata

File hashes

Hashes for streamlit_cookies_manager_ext-0.1.0.tar.gz
Algorithm Hash digest
SHA256 71262531d2bb4e42529efe176660b775a042aa176cc00884d5927d368953d8ec
MD5 72a67de9fdb97f372812284c84490697
BLAKE2b-256 0237a521b1e4c8bd562d724b3bc181fc58c1058f3d8d94d9721dd6f64d9f80bf

See more details on using hashes here.

File details

Details for the file streamlit_cookies_manager_ext-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_cookies_manager_ext-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5fb319531344dcd0bb1668d876fdcadadf27dd96d8958c7c71a5520a890c23bc
MD5 e1402e910cbe9fe4b23e8f464eea611f
BLAKE2b-256 68716378450dc12bfe5a0eb8defb4ab45423cd01e35aea0bb1fc3f4186a50247

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