streamlit-cookies-manager-v2


Namestreamlit-cookies-manager-v2 JSON
Version 0.3.1 PyPI version JSON
download
home_pageNone
SummaryAccess and save cookies from Streamlit - Modernized fork with st.cache_data fix, uv package manager, and updated Node dependencies
upload_time2025-08-26 14:45:12
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseApache-2.0
keywords browser-storage cookies session-management streamlit streamlit-component
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Streamlit Cookies Manager v2

> **Note**: This is a modernized fork of the original [streamlit-cookies-manager](https://github.com/ktosiek/streamlit-cookies-manager) by Tomasz Kontusz. The core functionality and most of the codebase remains his work. This fork updates the package for Streamlit 1.18+ compatibility and modern Python tooling.

## What's New in This Fork

- ✅ **Compatible with Streamlit 1.18+** - Uses `st.cache_data` instead of deprecated `st.cache`
- ✅ **Updated Dependencies** - All dependencies updated to latest stable versions
- ✅ **Modern Build System** - Switched from Poetry to UV (by Astral) for faster dependency management
- ✅ **Python 3.9+ Support** - Tested with Python 3.9, 3.10, 3.11, 3.12, and 3.13
- ✅ **PEP 621 Compliant** - Uses modern `pyproject.toml` format

## Installation

### From PyPI
```bash
pip install streamlit-cookies-manager-v2

# Or using UV
uv pip install streamlit-cookies-manager-v2
```

### From GitHub (Development)
```bash
pip install git+https://github.com/JohnDoeData/streamlit-cookies-manager.git

# Or using UV
uv pip install git+https://github.com/JohnDoeData/streamlit-cookies-manager.git
```

## Usage

Access and change browser cookies from Streamlit scripts:

```python
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="myapp/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
```

## Features

### Basic Cookie Manager
```python
from streamlit_cookies_manager import CookieManager

cookies = CookieManager()
if not cookies.ready():
    st.stop()

# Get a cookie
value = cookies.get('cookie_name')

# Set a cookie
cookies['cookie_name'] = 'cookie_value'

# Delete a cookie
del cookies['cookie_name']

# Save immediately (without waiting for rerun)
cookies.save()
```

### Encrypted Cookie Manager
```python
from streamlit_cookies_manager import EncryptedCookieManager

cookies = EncryptedCookieManager(
    password="your_secret_password",
    prefix="myapp/",  # Optional: prefix for all cookies
)

# All operations are the same as CookieManager
# but cookie values are automatically encrypted/decrypted
```

## Requirements

- Python 3.9+
- Streamlit 1.18.0+
- cryptography

## Development

This project uses [UV](https://github.com/astral-sh/uv) for dependency management:

```bash
# Clone the repository
git clone https://github.com/JohnDoeData/streamlit-cookies-manager.git
cd streamlit-cookies-manager

# Create virtual environment
uv venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install dependencies
uv pip install -e .

# Build JavaScript component
cd streamlit_cookies_manager
npm install
npm run build
```

## Changes from Original

1. **Caching Update**: Replaced deprecated `@st.cache` with `@st.cache_data` for Streamlit 1.18+ compatibility
2. **Dependency Updates**: Updated all Python and JavaScript dependencies to latest stable versions
3. **Build System**: Migrated from Poetry to UV for faster, more reliable dependency management
4. **Package Format**: Updated to PEP 621 compliant `pyproject.toml` format
5. **Version**: Continuing from 0.3.1 to show continuity from the original project

## Credits

**Original Author**: [Tomasz Kontusz](https://github.com/ktosiek) - [streamlit-cookies-manager](https://github.com/ktosiek/streamlit-cookies-manager)

**Current Maintainer**: [JohnDoeData](https://github.com/JohnDoeData)

This fork is maintained to ensure compatibility with modern Streamlit versions. The majority of the codebase and functionality was created by the original author.

## License

Apache-2.0 (same as original)
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "streamlit-cookies-manager-v2",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "JohnDoeData <johndoe_data@outlook.com>",
    "keywords": "browser-storage, cookies, session-management, streamlit, streamlit-component",
    "author": null,
    "author_email": "Tomasz Kontusz <tomasz.kontusz@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/31/34/ca8563a1766f48aa81c9fe5798edf53ae05409e622c21e61b2f022ec6f46/streamlit_cookies_manager_v2-0.3.1.tar.gz",
    "platform": null,
    "description": "# Streamlit Cookies Manager v2\n\n> **Note**: This is a modernized fork of the original [streamlit-cookies-manager](https://github.com/ktosiek/streamlit-cookies-manager) by Tomasz Kontusz. The core functionality and most of the codebase remains his work. This fork updates the package for Streamlit 1.18+ compatibility and modern Python tooling.\n\n## What's New in This Fork\n\n- \u2705 **Compatible with Streamlit 1.18+** - Uses `st.cache_data` instead of deprecated `st.cache`\n- \u2705 **Updated Dependencies** - All dependencies updated to latest stable versions\n- \u2705 **Modern Build System** - Switched from Poetry to UV (by Astral) for faster dependency management\n- \u2705 **Python 3.9+ Support** - Tested with Python 3.9, 3.10, 3.11, 3.12, and 3.13\n- \u2705 **PEP 621 Compliant** - Uses modern `pyproject.toml` format\n\n## Installation\n\n### From PyPI\n```bash\npip install streamlit-cookies-manager-v2\n\n# Or using UV\nuv pip install streamlit-cookies-manager-v2\n```\n\n### From GitHub (Development)\n```bash\npip install git+https://github.com/JohnDoeData/streamlit-cookies-manager.git\n\n# Or using UV\nuv pip install git+https://github.com/JohnDoeData/streamlit-cookies-manager.git\n```\n\n## Usage\n\nAccess and change browser cookies from Streamlit scripts:\n\n```python\nimport os\nimport streamlit as st\nfrom streamlit_cookies_manager import EncryptedCookieManager\n\n# This should be on top of your script\ncookies = EncryptedCookieManager(\n    # This prefix will get added to all your cookie names.\n    # This way you can run your app on Streamlit Cloud without cookie name clashes with other apps.\n    prefix=\"myapp/streamlit-cookies-manager/\",\n    # You should really setup a long COOKIES_PASSWORD secret if you're running on Streamlit Cloud.\n    password=os.environ.get(\"COOKIES_PASSWORD\", \"My secret password\"),\n)\nif not cookies.ready():\n    # Wait for the component to load and send us current cookies.\n    st.stop()\n\nst.write(\"Current cookies:\", cookies)\nvalue = st.text_input(\"New value for a cookie\")\nif st.button(\"Change the cookie\"):\n    cookies['a-cookie'] = value  # This will get saved on next rerun\n    if st.button(\"No really, change it now\"):\n        cookies.save()  # Force saving the cookies now, without a rerun\n```\n\n## Features\n\n### Basic Cookie Manager\n```python\nfrom streamlit_cookies_manager import CookieManager\n\ncookies = CookieManager()\nif not cookies.ready():\n    st.stop()\n\n# Get a cookie\nvalue = cookies.get('cookie_name')\n\n# Set a cookie\ncookies['cookie_name'] = 'cookie_value'\n\n# Delete a cookie\ndel cookies['cookie_name']\n\n# Save immediately (without waiting for rerun)\ncookies.save()\n```\n\n### Encrypted Cookie Manager\n```python\nfrom streamlit_cookies_manager import EncryptedCookieManager\n\ncookies = EncryptedCookieManager(\n    password=\"your_secret_password\",\n    prefix=\"myapp/\",  # Optional: prefix for all cookies\n)\n\n# All operations are the same as CookieManager\n# but cookie values are automatically encrypted/decrypted\n```\n\n## Requirements\n\n- Python 3.9+\n- Streamlit 1.18.0+\n- cryptography\n\n## Development\n\nThis project uses [UV](https://github.com/astral-sh/uv) for dependency management:\n\n```bash\n# Clone the repository\ngit clone https://github.com/JohnDoeData/streamlit-cookies-manager.git\ncd streamlit-cookies-manager\n\n# Create virtual environment\nuv venv\nsource .venv/bin/activate  # On Windows: .venv\\Scripts\\activate\n\n# Install dependencies\nuv pip install -e .\n\n# Build JavaScript component\ncd streamlit_cookies_manager\nnpm install\nnpm run build\n```\n\n## Changes from Original\n\n1. **Caching Update**: Replaced deprecated `@st.cache` with `@st.cache_data` for Streamlit 1.18+ compatibility\n2. **Dependency Updates**: Updated all Python and JavaScript dependencies to latest stable versions\n3. **Build System**: Migrated from Poetry to UV for faster, more reliable dependency management\n4. **Package Format**: Updated to PEP 621 compliant `pyproject.toml` format\n5. **Version**: Continuing from 0.3.1 to show continuity from the original project\n\n## Credits\n\n**Original Author**: [Tomasz Kontusz](https://github.com/ktosiek) - [streamlit-cookies-manager](https://github.com/ktosiek/streamlit-cookies-manager)\n\n**Current Maintainer**: [JohnDoeData](https://github.com/JohnDoeData)\n\nThis fork is maintained to ensure compatibility with modern Streamlit versions. The majority of the codebase and functionality was created by the original author.\n\n## License\n\nApache-2.0 (same as original)",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Access and save cookies from Streamlit - Modernized fork with st.cache_data fix, uv package manager, and updated Node dependencies",
    "version": "0.3.1",
    "project_urls": {
        "Bug Tracker": "https://github.com/JohnDoeData/streamlit-cookies-manager/issues",
        "Homepage": "https://github.com/JohnDoeData/streamlit-cookies-manager",
        "Original Project": "https://github.com/ktosiek/streamlit-cookies-manager",
        "Repository": "https://github.com/JohnDoeData/streamlit-cookies-manager.git"
    },
    "split_keywords": [
        "browser-storage",
        " cookies",
        " session-management",
        " streamlit",
        " streamlit-component"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "7ed74cc9fead85cc997313e82caa8642693a3c8c00a7721604cf73449c921ab9",
                "md5": "c6a5db1c1e88edcda8296194eac79b4e",
                "sha256": "8d7f201fe7af42d5a739472cc7998500fe1aedba24b3418fafdc84466b311df5"
            },
            "downloads": -1,
            "filename": "streamlit_cookies_manager_v2-0.3.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c6a5db1c1e88edcda8296194eac79b4e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 556776,
            "upload_time": "2025-08-26T14:45:11",
            "upload_time_iso_8601": "2025-08-26T14:45:11.047699Z",
            "url": "https://files.pythonhosted.org/packages/7e/d7/4cc9fead85cc997313e82caa8642693a3c8c00a7721604cf73449c921ab9/streamlit_cookies_manager_v2-0.3.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "3134ca8563a1766f48aa81c9fe5798edf53ae05409e622c21e61b2f022ec6f46",
                "md5": "53f5824573dbf1da3dba1598e34e2944",
                "sha256": "ef327bd4b1c74a1c7a77a5769c1fa209adea762fddf9771918efc62306549c84"
            },
            "downloads": -1,
            "filename": "streamlit_cookies_manager_v2-0.3.1.tar.gz",
            "has_sig": false,
            "md5_digest": "53f5824573dbf1da3dba1598e34e2944",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 311308,
            "upload_time": "2025-08-26T14:45:12",
            "upload_time_iso_8601": "2025-08-26T14:45:12.994707Z",
            "url": "https://files.pythonhosted.org/packages/31/34/ca8563a1766f48aa81c9fe5798edf53ae05409e622c21e61b2f022ec6f46/streamlit_cookies_manager_v2-0.3.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-26 14:45:12",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "JohnDoeData",
    "github_project": "streamlit-cookies-manager",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "streamlit-cookies-manager-v2"
}
        
Elapsed time: 0.52711s