NathanChen198 / streamlit-cookies-controller

Control client browser cookie for the site.
MIT License
31 stars 1 forks source link
cookie python streamlit-component

Welcome to Streamlit Cookie Controller 🍪

PyPI Download GitHub GitHub license GitHub issues GitHub pull requests

Control client browser cookie for the site.

What is Streamlit Cookie Controller?

streamlit-cookies-controller let you

from/to the client browser. It use universal-cookie package to access the cookies.

Installation

Open a terminal and run:

pip install streamlit-cookies-controller

Quickstart

Create a new file example.py

import streamlit as st
from streamlit_cookies_controller import CookieController

st.set_page_config('Cookie QuickStart', '🍪', layout='wide')

controller = CookieController()

# Set a cookie
controller.set('cookie_name', 'testing')
st.write(st.session_state)

# Get all cookies
cookies = controller.getAll()
st.write(cookies)

# Get a cookie
cookie = controller.get('cookie_name')
st.write(cookie)

# Remove a cookie
controller.remove('cookie_name')
st.write(st.session_state)

Run the streamlit app

streamlit run example.py

Change Log

Version 0.0.1