PHPackages                             switon/session - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. switon/session

ActiveLibrary[HTTP &amp; Networking](/categories/http)

switon/session
==============

Redis-backed HTTP session state with deferred writes and lifecycle events for Switon Framework

v1.0.0(1mo ago)021MITPHPPHP &gt;=8.3CI passing

Since Jun 6Pushed 2mo agoCompare

[ Source](https://github.com/switon-php/session)[ Packagist](https://packagist.org/packages/switon/session)[ Docs](https://github.com/switon-php/session)[ RSS](/packages/switon-session/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (8)Versions (2)Used By (1)

Switon Session Package
======================

[](#switon-session-package)

[![Session CI](https://camo.githubusercontent.com/ea791ea69663bb9021543c3ec56c5ffdc74f9238208b80676394f2313cdfbc75/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f737769746f6e2d7068702f73657373696f6e2f63692e796d6c3f6272616e63683d6d61696e266c6162656c3d53657373696f6e2532304349)](https://github.com/switon-php/session/actions/workflows/ci.yml) [![PHP 8.3+](https://camo.githubusercontent.com/c03f51341eebaefabbf137e291b20523fc74b4ffd084406d88524d266d95085d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e332532422d373737424234)](https://www.php.net/)

Switon's HTTP session layer for request-scoped state, Redis-backed persistence, and session lookup, update, and invalidation by ID.

Highlights
----------

[](#highlights)

- **Session state:** `SessionInterface` covers 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:** `BagInterface` keeps component-specific keys under one namespace.
- **Session control:** apps can look up, update, or revoke any session by ID.

Installation
------------

[](#installation)

```
composer require switon/session
```

Quick Start
-----------

[](#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:

License
-------

[](#license)

MIT.

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance87

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

49d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/dc0f20ad15b0ae9fbf9c6e2cd3008692b0c88a877ec8d3e0119211314bf86fc8?d=identicon)[switon](/maintainers/switon)

---

Top Contributors

[![switon-php](https://avatars.githubusercontent.com/u/247358032?v=4)](https://github.com/switon-php "switon-php (6 commits)")

---

Tags

cookieshttpsessionswitonhttpsessioncookiesswiton

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/switon-session/health.svg)

```
[![Health](https://phpackages.com/badges/switon-session/health.svg)](https://phpackages.com/packages/switon-session)
```

###  Alternatives

[nette/http

🌐 Nette Http: abstraction for HTTP request, response and session. Provides careful data sanitization and utility for URL and cookies manipulation.

49119.8M612](/packages/nette-http)[aplus/app

Aplus Framework App Project

5991.6M1](/packages/aplus-app)[sunrise/http-router

A powerful solution as the foundation of your project.

17451.8k11](/packages/sunrise-http-router)[delight-im/cookie

Modern cookie management for PHP

1681.3M15](/packages/delight-im-cookie)[paragonie/cookie

Modern cookie management for PHP 7

5757.2k2](/packages/paragonie-cookie)[amphp/http-client-cookies

Automatic cookie handling for Amp's HTTP client.

14803.6k13](/packages/amphp-http-client-cookies)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
