PHPackages                             syntactical/session - 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. syntactical/session

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

syntactical/session
===================

Bare bones drop in replacement for native PHP sessions with alternate storage repositories

1.0.0(10y ago)139[1 issues](https://github.com/craigballinger/php-session/issues)PHPPHP &gt;=5.4.0

Since Dec 2Pushed 10y ago1 watchersCompare

[ Source](https://github.com/craigballinger/php-session)[ Packagist](https://packagist.org/packages/syntactical/session)[ Docs](https://github.com/craigballinger/php-session)[ RSS](/packages/syntactical-session/feed)WikiDiscussions master Synced 4w ago

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

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

[](#php-session-handler)

This library is a drop in replacement for PHP's native session handling. It exposes an interface for alternate storage repositories using the SessionHandler class introduced in 5.4.

\##Usage Install the library using composer

```
composer install syntactical/session

```

\##Using a PDO MySQL session store

Create the table:

```
CREATE TABLE `sessions` (
  `id` varchar(40) NOT NULL DEFAULT '0',
  `ip` int(10) NOT NULL DEFAULT '0',
  `user_agent` varchar(50) NOT NULL,
  `last_activity` int(10) unsigned NOT NULL DEFAULT '0',
  `data` text NOT NULL,
  PRIMARY KEY (`id`),
  KEY `last_activity` (`last_activity`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
```

Bootstrap the library:

```
$db = new PDO('mysql:host=your.db.host;dbname=db','username','password');
$table = 'sessions';
$storage = new MySQLStorage($db, $table);
$handler = new Session($storage);

session_set_save_handler($handler, true);
session_start();
```

You can now use the $\_SESSION superglobal and session\_\* functions as you would natively, but sessions will be stored in MySQL rather than the filesystem.

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

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

3863d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/890529?v=4)[Craig Ballinger](/maintainers/craigballinger)[@craigballinger](https://github.com/craigballinger)

### Embed Badge

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

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

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k116.5M113](/packages/jdorn-sql-formatter)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M87](/packages/propel-propel1)[jfelder/oracledb

Oracle DB driver for Laravel

11518.4k](/packages/jfelder-oracledb)

PHPackages © 2026

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