Lightweight session management library for PHP with pluggable handlers

Installs: 16

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/codemonster-ru/session

v1.0.0 2025-10-24 14:54 UTC

This package is auto-updated.

Last update: 2025-10-24 15:01:14 UTC


README

Latest Version on Packagist Total Downloads License Tests

Lightweight session management library for PHP โ€” object-oriented.

๐Ÿ“ฆ Installation

composer require codemonster-ru/session

๐Ÿš€ Usage

Basic example

use Codemonster\Session\Session;

// Start session (default: file storage)
Session::start();

// Store values
Session::put('user', 'Vasya');
Session::put('role', 'admin');

// Retrieve values
echo Session::get('user'); // Vasya

// Remove values
Session::forget('role');

// Get all session data
print_r(Session::all());

// Destroy current session
Session::destroy();

Using Array handler (for tests or CLI)

Session::start('array');
Session::put('debug', true);

echo Session::get('debug'); // true

Using custom handler

use Codemonster\Session\Session;
use App\Session\RedisSessionHandler;

$redis = new Redis();
$redis->connect('127.0.0.1', 6379);

$handler = new RedisSessionHandler($redis);

Session::start(customHandler: $handler);
Session::put('user_id', 42);

๐Ÿงช Testing

You can run tests with the command:

composer test

๐Ÿ‘จโ€๐Ÿ’ป Author

Kirill Kolesnikov

๐Ÿ“œ License

MIT