PHPackages                             geekjob/expressjs-php-session-handler - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. geekjob/expressjs-php-session-handler

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

geekjob/expressjs-php-session-handler
=====================================

Session handler compatible with Node.js express-session handler

1.2.2(3y ago)1113MITPHPPHP &gt;=7.2

Since Jul 15Pushed 3y ago1 watchersCompare

[ Source](https://github.com/frontdevops/expressjs-php-session-handler)[ Packagist](https://packagist.org/packages/geekjob/expressjs-php-session-handler)[ RSS](/packages/geekjob-expressjs-php-session-handler/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (1)DependenciesVersions (3)Used By (0)

PHP implementation of Node.js Express Session Handler
=====================================================

[](#php-implementation-of-nodejs-express-session-handler)

This library is meant to work as a Session Handler for PHP that is compatible with [express-session](https://github.com/expressjs/session).

This library writed for SOA (Service-oriented architecture) projects for sharing session between a Node.js application and services writed on PHP.

Requirements
------------

[](#requirements)

- **PHP**: `8.1` or greater
- **phpredis**
- **php\_serialize** Standart PHP Serialize Handler.

This library now created for using [express-session](https://github.com/expressjs/session)with the [connect-redis](https://github.com/tj/connect-redis) Session Store as common session store.

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

[](#installation)

### Install Redis

[](#install-redis)

You can install it using `pecl install redis`

In Docker file:

```
FROM php:fpm
...
RUN pecl install redis && docker-php-ext-enable redis
```

### Composer

[](#composer)

Just run to get the package from [packagist.org](https://packagist.org/packages/geekjob/expressjs-php-session-handler):

```
composer require geekjob/expressjs-php-session-handler
```

Setup and Usage
---------------

[](#setup-and-usage)

### Configure Node.js application

[](#configure-nodejs-application)

```
app.use(session({
	name: 'sid',
	secret: 'secret key',
	cookie: {
		// Share cookie through sub domains if you use many domains for service architecture
		domain : '.your.domain',
		maxAge : Date.now() + 60000
	},
	store: new RedisStore({
		host  : 'redis',
		port  : 6379,
		client: redis,
		prefix: 'session:',
		ttl   : 3600 // 60 min
	})
}));
```

### Configure runtime

[](#configure-runtime)

```
require_once 'vendor/autoload.php';

\GeekJOB\ExpressjsSessionHandler::register(
	name  : 'sid',
	secret: 'secret key',
	cookie: [
		'domain'  => '.your.domain', // Share cookie through sub domains
		'path'    => '/',
		'maxage'  => strtotime('+1hour')-time(), // Set maxage
	],
	store : [
		'handler' => 'redis',
		'path'    => 'tcp://127.0.0.1:6379',
		'prefix'  => 'session:',
        	'ttl'	  => 3600 // 60 min
	],
	secure: false // Set to true if signature verification is needed.
);
```

or use list like way for config

```
\GeekJOB\ExpressjsSessionHandler::register(
    [
	'name'   => 'sid',
	'secret' => 'secret key',
	'cookie' => [
		'domain'  => '.your.domain', // Share cookie through sub domains
		'path'    => '/',
		'maxage'  => strtotime('+1hour')-time(), // Set maxage
	],
	'store' => [
		'handler' => 'redis',
		'path'    => 'tcp://127.0.0.1:6379',
		'prefix'  => 'session:',
        	'ttl'	  => 3600 // 60 min
	],
	'secure' => false // Set to true if signature verification is needed.
    ]
);
```

### Configure for production server via php.ini file

[](#configure-for-production-server-via-phpini-file)

```
session.session_name = sid
session.save_handler = redis
session.save_path = "tcp://127.0.0.1/?prefix=session:"
session.serialize_handler = php_serialize

; After this number of seconds, stored data will be seen as 'garbage' and
; cleaned up by the garbage collection process.
; http://php.net/session.gc-maxlifetime
; default: session.gc_maxlifetime = 1440
; Redis Sessions use this value for setting TTL
session.gc_maxlifetime =

; Lifetime in seconds of cookie or, if 0, until browser is restarted.
; http://php.net/session.cookie-lifetime
session.cookie_lifetime =
```

```
require_once 'vendor/autoload.php';

\GeekJOB\ExpressjsSessionHandler::register(
    secret: 'secret key',
    cookie: [
	'domain'  => '.your.domain', // Share cookie through sub domains
	'path'    => '/',
    ]
);
```

### TODO

[](#todo)

- MongodDB support
- Dragonfly support
- Unit tests :)

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

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

2

Last Release

1446d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/47718537?v=4)[Geekjob](/maintainers/geekjob)[@geekjob](https://github.com/geekjob)

---

Top Contributors

[![frontdevops](https://avatars.githubusercontent.com/u/3450932?v=4)](https://github.com/frontdevops "frontdevops (13 commits)")

### Embed Badge

![Health badge](/badges/geekjob-expressjs-php-session-handler/health.svg)

```
[![Health](https://phpackages.com/badges/geekjob-expressjs-php-session-handler/health.svg)](https://phpackages.com/packages/geekjob-expressjs-php-session-handler)
```

PHPackages © 2026

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