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

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

gabbro-php/session
==================

Session Library

1.006523(7mo ago)00MITPHPPHP &gt;=8.0

Since Sep 29Pushed 7mo agoCompare

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

READMEChangelogDependencies (1)Versions (2)Used By (0)

Gabbro - Session Library
========================

[](#gabbro---session-library)

This library provides a flexible, framework-agnostic session management system for PHP.
It is designed as a replacement or alternative to PHP’s built-in `$_SESSION` handling, while keeping the same conceptual model of key/value session storage.

Key Features
------------

[](#key-features)

- **Interface-driven design**: The `SessionRegistry` interface defines a consistent contract for session handling, making it easy to plug in different storage backends.
- **Multiple implementations**:
    - **VolatileSessionRegistry** – in-memory sessions that only last for the duration of a request (no persistence).
    - **FileSessionRegistry** – file-based sessions, compatible with PHP’s default behavior but with more control and extensibility.
    - **StreamSessionRegistry** – stream-backed sessions (useful for custom storage like memory streams, sockets, or database-backed streams).
- **BaseSessionRegistry**: Provides shared logic for managing session key/value pairs, reducing duplication in implementations.
- **Custom session IDs**: Sessions use secure, random identifiers (base64url-encoded) that can be customized or replaced.

Why use this?
-------------

[](#why-use-this)

PHP’s built-in session handling is tightly coupled to files and the global `$_SESSION` superglobal.
This library decouples session logic from storage, allowing you to integrate sessions into more advanced architectures:

- Store session data in files, memory, or streams.
- Run without touching `$_SESSION`.
- Implement custom storage (Redis, databases, etc.) by extending `BaseSessionRegistry`.

Example Usage
-------------

[](#example-usage)

```
use gabbro\auth\FileSessionRegistry;

// Create a file-backed session
$session = new FileSessionRegistry();

// Set some data
$session->set("user_id", 123);

// Retrieve data
$userId = $session->get("user_id");

// Save to storage
$session->save();
```

Garbage Collection
------------------

[](#garbage-collection)

File-based sessions include lightweight garbage collection, triggered randomly during construction, to clean up expired session files. This mimics PHP’s native behavior but gives you more explicit control.

Extensibility
-------------

[](#extensibility)

The library is designed to be extended. You can easily create your own session registry by extending `BaseSessionRegistry` and implementing `save()`.

For example, you could implement a `DatabaseSessionRegistry` that stores serialized session data in a database table.

---

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance62

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity40

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

231d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ecf19012ac8ad546408e9ca1666b479831b495dc947b263987509a75acd7524b?d=identicon)[dbergloev](/maintainers/dbergloev)

---

Top Contributors

[![dbergloev](https://avatars.githubusercontent.com/u/1395583?v=4)](https://github.com/dbergloev "dbergloev (1 commits)")

### Embed Badge

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

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

PHPackages © 2026

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