--- id: starsessions version: "2.2.1" license: MIT license_treatment: permissive maintenance: active --- # starsessions — Advanced sessions for Starlette and FastAPI frameworks License: permissive · Maintenance: active · Downloads: 449.2K/mo ## What it is and what it does Starsessions is a session middleware library for Starlette and FastAPI that manages user session data across HTTP requests. It abstracts session storage behind a pluggable backend system, offering three built-in stores: CookieStore (client-side signed cookies), InMemoryStore (for testing), and RedisStore (for distributed deployments). The middleware handles cookie lifecycle, security defaults (HTTPS-only, browser-session lifetime by default), and optional autoloading to reduce boilerplate. The library is designed for developers building async web applications who need flexible session handling without reinventing session management. It supports rolling sessions (where inactivity resets the timeout), path and domain binding for cookies, and explicit session loading to avoid performance overhead. Dependencies are minimal (starlette and itsdangerous), and the package supports Python 3.8 through 3.13. Use it for: - Add session support to a FastAPI REST API with cookie-based authentication and 14-day rolling expiration - Store user preferences and shopping cart data in Redis for a multi-instance web application - Implement admin-only session cookies scoped to /admin paths with automatic cleanup on browser close - Unit test session behavior using InMemoryStore without external dependencies - Migrate from stateless JWT to session-based auth with automatic session extension on user activity ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Provides session management middleware for Starlette and FastAPI applications, supporting multiple storage backends including cookies, in-memory storage, and Redis with configurable expiration strategies. Yes. Starsessions is production-ready (Development Status 5), actively maintained, has zero known vulnerabilities, and solves a common problem in Starlette/FastAPI applications with minimal dependencies and flexible storage options. The permissive MIT license and broad Python version support (3.8–3.13) make it suitable for most projects. ## Install pip install starsessions uv add starsessions poetry add starsessions ## Installing starsessions Before you install: Low install friction with only two runtime dependencies (starlette and itsdangerous). The package is actively maintained with a recent commit on 2026-03-16 and has been in production use since 2021-06-24. License in practice: MIT license permits unrestricted use, modification, and distribution with minimal obligations—suitable for both open-source and commercial projects. Quickstart: pip install starsessions from starlette.applications import Starlette from starlette.middleware import Middleware from starsessions import CookieStore, SessionMiddleware, load_session session_store = CookieStore(secret_key='TOP SECRET') app = Starlette( middleware=[Middleware(SessionMiddleware, store=session_store, lifetime=3600 * 24 * 14)] ) async def view(request): await load_session(request) request.session['key'] = 'value' Verify before relying: - Whether Redis extra installation (starsessions[redis]) is required for production deployments or optional for development - Performance characteristics when handling high-concurrency session loads across different storage backends ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 449.2K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags starlette session middleware, fastapi session management, asgi session store, cookie-based sessions, redis session storage, rolling sessions, session autoload middleware, session-management, asgi-middleware, starlette-fastapi [View on SkillFed](https://skillfed.io/packages/starsessions) · [View on PyPI](https://pypi.org/project/starsessions/)