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

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

jamiecressey/php-mysql-session-handler
======================================

MySQL PHP Session Handler

0.0.1(10y ago)1390014MITPHPPHP &gt;=5.4.0

Since Oct 6Pushed 10y ago2 watchersCompare

[ Source](https://github.com/JamieCressey/PHP-MySQL-Session-Handler)[ Packagist](https://packagist.org/packages/jamiecressey/php-mysql-session-handler)[ Docs](http://github.com/jayc89/php-mysql-session-handler)[ RSS](/packages/jamiecressey-php-mysql-session-handler/feed)WikiDiscussions master Synced 1mo ago

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

PHP MySQL Session Handler
=========================

[](#php-mysql-session-handler)

[![Latest Stable Version](https://camo.githubusercontent.com/9d662429d83807396af72cd6aa1c30fa2d21eeb59c615f8729edae91b907e330/68747470733a2f2f706f7365722e707567782e6f72672f6a616d6965637265737365792f7068702d6d7973716c2d73657373696f6e2d68616e646c65722f762f737461626c652e706e67)](https://packagist.org/packages/jamiecressey/php-mysql-session-handler)[![Total Downloads](https://camo.githubusercontent.com/0e0e99c7eacc6bc48110038e7c75acbea33c2478c536c7e49c4c7de0503fcc7e/68747470733a2f2f706f7365722e707567782e6f72672f6a616d6965637265737365792f7068702d6d7973716c2d73657373696f6e2d68616e646c65722f646f776e6c6f6164732e706e67)](https://packagist.org/packages/jamiecressey/php-mysql-session-handler)[![Bitdeli Badge](https://camo.githubusercontent.com/5292af9d1f00f039721e7590daa9264bdcdf8183a211bc8ee0070ef08a01d61b/68747470733a2f2f64327765637a68766c38323376302e636c6f756466726f6e742e6e65742f6a616d6965637265737365792f7068702d6d7973716c2d73657373696f6e2d68616e646c65722f7472656e642e706e67)](https://bitdeli.com/free "Bitdeli Badge")

This repository contains a custom PHP session handler using MySQL as a backend. The class has been tested successfully using PHP-FPM and HHVM. To get started, it is recommended, although not required, this class is used in conjunction with [PHP-MySQL-PDO-Database-Class](https://github.com/JamieCressey/php-mysql-pdo-database-class).

How to Install
--------------

[](#how-to-install)

#### using [Composer](http://getcomposer.org/)

[](#using-composer)

Create a composer.json file in your project root:

```
{
    "require": {
        "jamiecressey/php-mysql-session-handler": "dev-master"
    }
}
```

Then run the following composer command:

```
$ php composer.phar install
```

How to use
----------

[](#how-to-use)

```
CREATE TABLE IF NOT EXISTS `sessions` (
    `id` varchar(32) NOT NULL,
    `timestamp` int(10) unsigned DEFAULT NULL,
    `data` mediumtext,
    PRIMARY KEY (`id`),
    KEY `timestamp` (`timestamp`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
```

```
require 'vendor/autoload.php';
$handler = new \JamieCressey\SessionHandler\SessionHandler();

// Pass DB details to create a new MySQLi connection
$handler->setDbDetails('localhost', 'username', 'password', 'database');
// OR alternatively, inject an existing MySQLi resource
// $db = new Db(); // See: https://github.com/jamiecressey/php-mysql-pdo-database-class
// $handler->setDbConnection($db);

$handler->setDbConnection($db);
$handler->setDbTable('sessions');
session_set_save_handler($handler, true);
session_start();
```

Authors
-------

[](#authors)

[Jamie Cressey](https://github.com/JamieCressey)

License
-------

[](#license)

MIT Public License

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community12

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

3868d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9d11f2e76de7ba7b3ebe3df115f6e81842fb6b7f0896189c53f2116fd3f35e3c?d=identicon)[jayc89](/maintainers/jayc89)

---

Top Contributors

[![JamieCressey](https://avatars.githubusercontent.com/u/6462914?v=4)](https://github.com/JamieCressey "JamieCressey (8 commits)")

---

Tags

phpmysqlsessions

### Embed Badge

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

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

###  Alternatives

[clouddueling/mysqldump-php

PHP version of mysqldump cli that comes with MySQL

1.3k22.9k](/packages/clouddueling-mysqldump-php)[stefangabos/zebra_database

An advanced, compact and lightweight MySQL database wrapper library, built around PHP's MySQLi extension.

11812.0k](/packages/stefangabos-zebra-database)[eftec/pdoone

Minimaist procedural PDO wrapper library

1105.9k9](/packages/eftec-pdoone)[popphp/pop-db

Pop Db Component for Pop PHP Framework

1814.6k11](/packages/popphp-pop-db)[matthew-p/docker-server

Universal docker server, Nginx, PHP-FPM, MySql, Redis

112.8k](/packages/matthew-p-docker-server)

PHPackages © 2026

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