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

ActiveLibrary

carry0987/session-manager
=========================

Flexible and secure session management for PHP. This library provides an object-oriented wrapper for PHP's native session handling functions, implementing SessionHandlerInterface for easy integration with existing projects. It also comes with additional features like session encryption and database storage handlers for scalable applications.

1.0.11(1mo ago)058MITPHPPHP &gt;=7.4

Since Jan 9Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/carry0987/SessionManager)[ Packagist](https://packagist.org/packages/carry0987/session-manager)[ RSS](/packages/carry0987-session-manager/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)DependenciesVersions (13)Used By (0)

SessionManager
==============

[](#sessionmanager)

[![Packgist](https://camo.githubusercontent.com/b1bbd5626488447d5724c9ea01464b028f91166195326244bcb64924ae3b6eaa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6361727279303938372f73657373696f6e2d6d616e616765722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/carry0987/session-manager)
Modern PHP Session Management Library

Introduction
------------

[](#introduction)

`SessionManager` is a modern PHP session management library that provides an object-oriented wrapper around PHP's native session handling functions. It implements the `SessionHandlerInterface`, allowing for easy integration with existing projects. Additionally, it offers extra features such as session encryption and database storage handlers for scalable applications.

Features
--------

[](#features)

- Object-oriented session management.
- Protection against session fixation attacks.
- Automatic handling of session expiration.
- CSRF token generation and validation mechanisms.
- Easy integration into existing projects or frameworks.
- Support for custom session names and cookie parameters.

Installation
------------

[](#installation)

You can install `SessionManager` via Composer:

```
composer require carry0987/session-manager
```

Usage
-----

[](#usage)

Here is a basic example of how to use `SessionManager`:

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

use carry0987\SessionManager\SessionManager;

// Create a SessionManager instance, you may optionally supply a custom session name and cookie parameters
$sessionManager = new SessionManager('MY_SESSION_NAME', [
    'lifetime' => 3600,           // Cookie lifetime
    'secure' => true,             // Send only over HTTPS
    'httponly' => true,           // Accessible only through the HTTP protocol
    'samesite' => 'Strict'        // Strict same-site policy
]);

// Set a session variable
$sessionManager->set('username', 'user123');

// Retrieve a session variable
$username = $sessionManager->get('username');

// Destroy the session
$sessionManager->destroy();

// Renew the session
$sessionManager->renew('MY_SESSION_NAME');
```

Security Features
-----------------

[](#security-features)

- Session fixation attack protection: `SessionManager` regenerates the session ID periodically.
- Session expiration mechanism: Sessions automatically expire after a period of inactivity.
- CSRF protection: Generates and validates CSRF tokens.
- Secure cookie parameters: Cookies are marked as HttpOnly and Secure by default to enhance security.

API Reference
-------------

[](#api-reference)

Here is a list of methods provided by `SessionManager`:

- `set($key, $value)`: Set a session variable.
- `get($key)`: Get a session variable.
- `exists($key)`: Check if a session variable exists.
- `remove($key)`: Remove a session variable.
- `destroy()`: Destroy the session.
- For more detailed methods and usage instructions, see the code comments.

Contributing
------------

[](#contributing)

If you have any suggestions for improvement or feature requests, please open an issue or submit a pull request.

License
-------

[](#license)

This project is licensed under the MIT License. See the LICENSE file for more information.

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance88

Actively maintained with recent releases

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

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

Every ~72 days

Recently: every ~185 days

Total

12

Last Release

58d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1f43bad259478092c4ff269518aa9a0c8e91a537a67272877041b4bc1f25cfe8?d=identicon)[carry0987](/maintainers/carry0987)

---

Top Contributors

[![carry0987](https://avatars.githubusercontent.com/u/12984973?v=4)](https://github.com/carry0987 "carry0987 (23 commits)")

---

Tags

composerphpsession-management

### Embed Badge

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

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

PHPackages © 2026

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