PHPackages                             svk27/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. svk27/mysql-session-handler

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

svk27/mysql-session-handler
===========================

MySQL PHP Session Handler - Custom Use - SekureSessions

1.1.1(4y ago)025MITPHPPHP &gt;=7.0.0

Since Oct 6Pushed 4y agoCompare

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

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

PHP 7.0+ MySQL Session Handler
==============================

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

This repository contains a custom PHP session handler using MySQL as a backend.

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

[](#how-to-install)

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

[](#using-composer)

Install composer if you haven't already.

Navigate to your project's directory and run the following command:

```
composer require "svk27/mysql-session-handler"
```

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

[](#how-to-use)

Below is a script demonstrating how to use this tool.

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

# Create your MySQL database connection
$db = new mysqli('localhost', 'username', 'password', 'database');

# Create the session handler using that connection and pass it the name of the table
# The handler will try to create it if it doesn't already exist.
$handler = new \SekureSessions\SessionHandler\SessionHandler($db, 'my_sessions_table');

# Tell PHP to use the handler we just created.
session_set_save_handler($handler, true);

# Start your session
session_start();

# Set a session variable.
$_SESSION['my_session_variable'] = 'some data here';
```

### Manually Creating Sessions Table

[](#manually-creating-sessions-table)

The tool will try to use the database connection to create the sessions table if it doesn't already exist. If you provide the handler with user credentials that haven't been granted the rights to create tables, you can manually create the table with the following SQL statement:

```
CREATE TABLE IF NOT EXISTS `sessions` (
    `id` varchar(32) NOT NULL,
    `modified_timestamp` timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    `data` mediumtext,
    PRIMARY KEY (`id`),
    KEY `modified_timestamp` (`modified_timestamp`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
```

Authors
-------

[](#authors)

- [Programster](https://github.com/Programster)
- [Jamie Cressey](https://github.com/JamieCressey)
- [Souvik Ghosh](https://souvikghosh.com/)

License
-------

[](#license)

MIT Public License

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~295 days

Recently: every ~309 days

Total

8

Last Release

1801d ago

Major Versions

0.1.1 → 1.0.02018-01-14

PHP version history (2 changes)0.0.1PHP &gt;=5.4.0

0.1.0PHP &gt;=7.0.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/99f92fb373b74872bf318b1d64f32b067d775594d6556a8529573742c95731bb?d=identicon)[svk27](/maintainers/svk27)

---

Top Contributors

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

### Embed Badge

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

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

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.3k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M543](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M209](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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