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

ActiveLibrary

genai/session
=============

Session component with pluggable storage: native files (default), a project file dir (cache/session), or a database (PDO). A small Session API over native PHP sessions; a SessionStore save-handler decides where the data lives. Driver chosen from the \[session\] config group. PHP 5.3-safe runtime.

v1.0.5(1mo ago)0129↓20.4%Apache-2.0PHPPHP &gt;=5.3.0CI passing

Since Jul 3Pushed 1mo agoCompare

[ Source](https://github.com/GenAIIO/php-session)[ Packagist](https://packagist.org/packages/genai/session)[ RSS](/packages/genai-session/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (4)Dependencies (2)Versions (7)Used By (0)

genai/session
=============

[](#genaisession)

A session component with **pluggable storage**. A small `Session` API over native PHP sessions; a `SessionStore` save-handler decides *where* the data lives:

driverstoreuse it for`default`native filessingle server, simplest`file``FileStore`project-local files (`cache/session/`)`database``PdoStore`multiple servers (shared `sessions` table)The cookie, session id, and GC stay native — only the read/write target changes.

API
---

[](#api)

```
$session->set('uid', 7);
$uid = $session->get('uid', 0);
$session->has('uid'); $session->remove('uid'); $session->pull('once');
$session->flash('msg', 'Saved!');       // available on the NEXT request
$msg = $session->getFlash('msg');
$session->regenerate();                  // on login (anti-fixation)
$session->destroy();                     // on logout
```

Starts **lazily** on first use, so responses that never touch the session set no cookie.

Config (`[session]` group, optional)
------------------------------------

[](#config-session-group-optional)

```
[session]
driver   = file          ; default | file | database
name     = KIDSAFE
lifetime = 0             ; cookie seconds (0 = until browser close)
path     = cache/session ; driver=file
table    = sessions      ; driver=database
```

Wiring (one bean)
-----------------

[](#wiring-one-bean)

The factory picks the store from config; the app decides whether it has a PDO to pass:

```
#[Configuration]
class SessionConfig
{
    #[Bean(\GenAI\Session\Session::class)]
    public function session(\GenAI\Session\Bundle\SessionProperty $cfg, \PDO $pdo)
    {
        return \GenAI\Session\SessionFactory::build($cfg, $pdo);   // omit $pdo if no DB
    }
}
```

Then inject `GenAI\Session\Session` anywhere and drop manual `session_start()`.

Notes
-----

[](#notes)

- `SessionProperty` auto-registers (the package declares `extra.genai.scan`); just `require genai/session`.
- PHP 5.3 has no `SessionHandlerInterface`, so this uses the 6-callback save-handler form plus a `session_write_close` shutdown hook (so custom stores flush before objects are destroyed).
- SameSite isn't set on the cookie (needs PHP 7.3+); httponly is always on, secure is auto on HTTPS.
- `database` needs `ext-pdo`. The table is created on first use; `UPDATE`-then-`INSERT` keeps it SQLite/MySQL-portable.

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance92

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

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

Total

6

Last Release

38d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/25e5bd31b5dd70d47cbdc738bded06dbabfba3d584acce63c2c4b4fb7847f39d?d=identicon)[jinnguyen](/maintainers/jinnguyen)

---

Top Contributors

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

### Embed Badge

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

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

PHPackages © 2026

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