switon / session
Redis-backed HTTP session state with deferred writes and lifecycle events for Switon Framework
v1.0.0
2026-06-06 13:43 UTC
Requires
- php: >=8.3
- psr/event-dispatcher: ^1.0
- switon/core: ^1.0
- switon/event: ^1.0
- switon/http: ^1.0
- switon/redis: ^1.0
Requires (Dev)
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^2.0
- switon/testing: ^1.0
README
Switon's HTTP session layer for request-scoped state, Redis-backed persistence, and session lookup, update, and invalidation by ID.
Highlights
- Session state:
SessionInterfacecovers read, write, remove, and destroy flows for request data. - Lifecycle visibility: session start, update, destroy, and failure states can be observed.
- Redis storage: session payloads can be stored in Redis with app-aware keys.
- Session bags:
BagInterfacekeeps component-specific keys under one namespace. - Session control: apps can look up, update, or revoke any session by ID.
Installation
composer require switon/session
Quick Start
use Switon\Core\Attribute\Autowired; use Switon\Session\SessionInterface; class AuthController { #[Autowired] protected SessionInterface $session; public function login(int $userId): void { $this->session->set('user_id', $userId); } public function logout(): void { $this->session->destroy(); } }
Docs: https://docs.switon.dev/latest/session
License
MIT.