PHPackages                             detain/session-samurai - 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. [Database &amp; ORM](/categories/database)
4. /
5. detain/session-samurai

ActiveLibrary[Database &amp; ORM](/categories/database)

detain/session-samurai
======================

🥷 Universal high-speed asynchronous (non-blocking) SessionHandlerInterface implementation for PHP supporting Semaphores, Mysqli, Redis, SQLite3, Symfony/Cache, WinCache, PhpFastCache, PHP-Cache, PDO, Memcached, FlySystem Filesystem, Illuminate, APCu, APC, OpCache, InfluxDB, WinCache, MongoDb and local file storage.

v2.0.0(12mo ago)8101↓100%[1 issues](https://github.com/detain/session-samurai/issues)[2 PRs](https://github.com/detain/session-samurai/pulls)GPL-3.0PHPPHP &gt;=8.0.0CI failing

Since Feb 17Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/detain/session-samurai)[ Packagist](https://packagist.org/packages/detain/session-samurai)[ RSS](/packages/detain-session-samurai/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (8)Versions (7)Used By (0)

Session Samurai 🥷
=================

[](#session-samurai-)

[![check](https://github.com/detain/session-samurai/actions/workflows/check.yml/badge.svg)](https://github.com/detain/session-samurai/actions/workflows/check.yml)

Universal high-speed asynchronous (non-blocking) SessionHandlerInterface implementation for PHP supporting Semaphores, Mysqli, Redis, SQLite3, Symfony/Cache, WinCache, PhpFastCache, PHP-Cache, PDO, Memcached, FlySystem Filesystem, Illuminate, APCu, APC, OpCache, InfluxDB, WinCache, MongoDb and local file storage.

"*Session handling is like a sword fight*
*You must think first before you move*
*When it's properly used it's almost invincible*"

Project Status
--------------

[](#project-status)

*Session Samurai 🥷* is fresh off the block and is still figuring out what it wants to do with its life. Soon it will grow into a mega-hotie that does the same stuff others do, only he makes it look good.

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

[](#installation)

Use [composer](http://getcomposer.org/) to include the save handler in your application.

```
composer requre detain/session-samurai
```

Usage
-----

[](#usage)

### Using Memcached

[](#using-memcached)

```
require 'vendor/autoload.php';  // set up autoloading using composer

$memcached = new \Memcached();  // create connection to memcached
$memcached->addServer('localhost', 11211);
$handler = new \Detain\SessionSamurai\MemcachedSessionHandler($memcached);
session_set_save_handler($handler, true);
```

### Using Redis

[](#using-redis)

```
$redis = new \Redis();
$redis->connect('127.0.0.1', 6379);
$handler = new \Detain\SessionSamurai\RedisSessionHandler($redis);
session_set_save_handler($handler, true);
```

Development notes
-----------------

[](#development-notes)

### Related sites with possibly good reference material

[](#related-sites-with-possibly-good-reference-material)

- [PHP: SessionHandlerInterface](https://www.php.net/manual/en/class.sessionhandlerinterface.php) - Manual
- [PHP: session\_set\_save\_handler](https://www.php.net/manual/en/function.session-set-save-handler.php) - Manual
- [PHP: Securing Session INI Settings](https://www.php.net/manual/en/session.security.ini.php) - Manual
- [Session Handler Life Cycle](https://gist.github.com/franksacco/d6e943c41189f8ee306c182bf8f07654): A complete overview of the php session handler life cycle\]
- [1ma/RedisSessionHandler](https://github.com/1ma/RedisSessionHandler): An alternative Redis session handler for PHP featuring per-session locking and session fixation protection
- [cballou/MongoSession](https://github.com/cballou/MongoSession): A PHP session handler wrapped around MongoDB.
- [josantonius/php-session](https://github.com/josantonius/php-session): PHP library for handling sessions
- [psr7-sessions/storageless](https://github.com/psr7-sessions/storageless): storage-less PSR-7 session support
- [ramazancetinkaya/session-handler](https://github.com/ramazancetinkaya/session-handler): A PHP library for secure session handling.
- [davidlienhard/sessionhandler](https://github.com/davidlienhard/sessionhandler): 🐘 php sessionhandler using database connection
- [zahycz/sessionless](https://github.com/zahycz/sessionless): Non-I/O blocking SessionHandler implementation using Nette/Caching
- [javis/php-memcached-sessions](https://github.com/javis/php-memcached-sessions): A PHP session handler that uses memcached to store session with multiple servers, failover and replication support.
- [PHP Cache](https://www.php-cache.com/en/latest/) - PHP-Cache Documentation
- [The Cache Component](https://symfony.com/doc/current/components/cache.html#available-cache-adapters) (Symfony Docs)
- [The Lock Component](https://symfony.com/doc/current/components/lock.html#available-stores) (Symfony Docs)

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance71

Regular maintenance activity

Popularity17

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.7% 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

Every ~271 days

Total

4

Last Release

363d ago

Major Versions

v0.0.2 → v1.0.02025-05-12

v1.0.0 → v2.0.02025-05-12

PHP version history (3 changes)v0.0.1PHP &gt;=5.3.0

v1.0.0PHP &gt;=5.3.0,&lt;8.0.0

v2.0.0PHP &gt;=8.0.0

### Community

Maintainers

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

---

Top Contributors

[![detain](https://avatars.githubusercontent.com/u/1364504?v=4)](https://github.com/detain "detain (89 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")[![mend-bolt-for-github[bot]](https://avatars.githubusercontent.com/in/16809?v=4)](https://github.com/mend-bolt-for-github[bot] "mend-bolt-for-github[bot] (1 commits)")

---

Tags

asynchronousflysystemmemcachedmongodbmysqlmysqlinon-blockingpdophpphp-cachephpfastcacheredissemaphoresessionsession-managementsessionhandlersessionhandlerinterfacesqlite3symfony-cachewincacheasynchronousnon-blockingFlysystemmysqlpdoredissemaphorememcachedapcumongodbsessionilluminatemysqliapcinfluxdbsqlite3doctrine-dbalphp cacheOpcachephpfastcachesession-managementsessionhandlersessionhandlerinterfacewinacchesyfony-cache

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[phpfastcache/phpfastcache

PHP Abstract Cache Class - Reduce your database call using cache system. Phpfastcache handles a lot of drivers such as Apc(u), Cassandra, CouchBase, Couchdb, Dynamodb, Firestore, Mongodb, Files, (P)redis, Leveldb, Memcache(d), Ravendb, Ssdb, Sqlite, Wincache, Xcache, Zend Data Cache.

2.4k5.0M130](/packages/phpfastcache-phpfastcache)[apix/cache

A thin PSR-6 cache wrapper with a generic interface to various caching backends emphasising cache taggging and indexing to Redis, Memcached, PDO/SQL, APC and other adapters.

114542.8k6](/packages/apix-cache)[matthiasmullie/scrapbook

Scrapbook is a PHP cache library, with adapters for e.g. Memcached, Redis, Couchbase, APCu, SQL and additional capabilities (e.g. transactions, stampede protection) built on top.

3212.5M32](/packages/matthiasmullie-scrapbook)[malkusch/lock

Mutex library for exclusive code execution.

9459.6M27](/packages/malkusch-lock)[desarrolla2/cache

Provides an cache interface for several adapters Apc, Apcu, File, Mongo, Memcache, Memcached, Mysql, Mongo, Redis is supported.

1322.5M47](/packages/desarrolla2-cache)[ezsql/ezsql

Advance database access library. Make interacting with a database ridiculously easy. An universal interchangeable CRUD system.

86946.7k](/packages/ezsql-ezsql)

PHPackages © 2026

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