PHPackages                             jeankassio/php-redis-session-manager - 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. [Caching](/categories/caching)
4. /
5. jeankassio/php-redis-session-manager

ActiveLibrary[Caching](/categories/caching)

jeankassio/php-redis-session-manager
====================================

PHP Session handler with Redis and WebSocket compatibility

1.5(1y ago)29MITPHPPHP &gt;=8.1

Since Jul 10Pushed 1y ago1 watchersCompare

[ Source](https://github.com/jeankassio/PHP-Redis-Session-Manager)[ Packagist](https://packagist.org/packages/jeankassio/php-redis-session-manager)[ RSS](/packages/jeankassio-php-redis-session-manager/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (8)Dependencies (1)Versions (9)Used By (0)

PHP Redis Session Manager
=========================

[](#php-redis-session-manager)

A simple and flexible PHP library for managing sessions using Redis, compatible with both **standard HTTP pages** and **WebSocket servers**.

---

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

[](#installation)

You can install via Composer:

```
composer require jeankassio/php-redis-session-manager
```

What is this?
-------------

[](#what-is-this)

PHP Redis Session Manager allows you to manage PHP sessions directly with Redis, supporting both:

- Traditional HTTP requests (automatic $\_SESSION)
- WebSocket environments (manual control of session read/write/delete)

Usage
-----

[](#usage)

### For Normal PHP Pages (Non-WebSocket)

[](#for-normal-php-pages-non-websocket)

```
require_once(dirname(__FILE__) ."/vendor/autoload.php");

use JeanKassio\RedisSessionManager;

$redisSessionManager = new RedisSessionManager('127.0.0.1', 6379, 'Password'); // Password is optional

$redisSessionManager->start(); // Starts the session and sets Redis as handler

if (!$redisSessionManager->checkRedis()) {
    // Handle Redis connection failure
}

// Set session values
$_SESSION['anything'] = 'anything';

// Get session values
$anything = $_SESSION['anything'];
```

### For WebSocket Usage

[](#for-websocket-usage)

**Do not call start() inside WebSocket servers!**

```
require_once(dirname(__FILE__) ."/vendor/autoload.php");

use JeanKassio\RedisSessionManager;

$redisSessionManager = new RedisSessionManager('127.0.0.1', 6379, 'Password'); // Password is optional

// Get session ID from your WebSocket logic
$sessionId = 'your-session-id';
$redisSessionManager->setSessionId($sessionId);

// Get full session as array
$session = $redisSessionManager->getSession();

// Set session data
$newSession = [
    'anything' => 'anything',
    'data' => $data,
    'username' => 'jeankassio'
];

$success = $redisSessionManager->setSession($newSession);

// Delete user session completely
$redisSessionManager->delSession();
```

PHPUnit
-------

[](#phpunit)

Inside folder:

```
cd /vendor/jeankassio/php-redis-session-manager
```

Edit the file phpunit.xml with your credentials:

```

```

run phpunit:

```
PHPUnit 10.5.47 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.3.22
Configuration: /www/wwwroot/----/session/vendor/jeankassio/php-redis-session-manager/phpunit.xml

.....                                                               5 / 5 (100%)

Time: 00:00.038, Memory: 24.94 MB

OK, but there were issues!
Tests: 5, Assertions: 8, PHPUnit Deprecations: 1.
```

Features
--------

[](#features)

- Password-protected Redis connection (optional)
- Lightweight and compatible with PHP-FPM, CLI, and Swoole/WebSocket
- Stores session as JSON internally
- Supports merging existing session data automatically

Important Notes
---------------

[](#important-notes)

- Redis must be running and reachable via the host and port you provide.
- When using inside WebSocket servers, make sure you:
    - Extract and set the sessionId before using
    - Avoid using session\_start() or $\_SESSION directly

[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)[![Redis](https://camo.githubusercontent.com/b74dadfdf4ad670e8182153ab743321bb545146b48b3b8aca7181d6edf435eba/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f72656469732d636f6d70617469626c652d677265656e)](https://camo.githubusercontent.com/b74dadfdf4ad670e8182153ab743321bb545146b48b3b8aca7181d6edf435eba/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f72656469732d636f6d70617469626c652d677265656e)

###  Health Score

30

—

LowBetter than 61% of packages

Maintenance46

Moderate activity, may be stable

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

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

Every ~0 days

Total

8

Last Release

402d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/26697873?v=4)[Jean Kássio](/maintainers/jeankassio)[@jeankassio](https://github.com/jeankassio)

---

Top Contributors

[![jeankassio](https://avatars.githubusercontent.com/u/26697873?v=4)](https://github.com/jeankassio "jeankassio (14 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jeankassio-php-redis-session-manager/health.svg)

```
[![Health](https://phpackages.com/badges/jeankassio-php-redis-session-manager/health.svg)](https://phpackages.com/packages/jeankassio-php-redis-session-manager)
```

###  Alternatives

[iazaran/smart-cache

Smart Cache is a caching optimization package designed to enhance the way your Laravel application handles data caching. It intelligently manages large data sets by compressing, chunking, or applying other optimization strategies to keep your application performant and efficient.

21114.2k](/packages/iazaran-smart-cache)[phpfastcache/phpssdb

PHP SSDB Driver for phpFastCache

14736.9k1](/packages/phpfastcache-phpssdb)[rapidwebltd/rw-file-cache

RW File Cache is a PHP File-based Caching Library. Its syntax is designed to closely resemble the PHP memcache extension.

15196.8k7](/packages/rapidwebltd-rw-file-cache)[yuzuru-s/redis-recommend

Wrapping Redis's sorted set APIs for specializing recommending operations.

392.9k](/packages/yuzuru-s-redis-recommend)[ichhabrecht/intcache

Turn uncachable page objects into cacheable links

193.9k](/packages/ichhabrecht-intcache)

PHPackages © 2026

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