PHPackages                             kooser/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. [Caching](/categories/caching)
4. /
5. kooser/session

ActiveLibrary[Caching](/categories/caching)

kooser/session
==============

Securely manage and preserve session data.

v5.0.1(5y ago)6152[2 issues](https://github.com/Kooser6/Session/issues)[3 PRs](https://github.com/Kooser6/Session/pulls)MITPHPPHP &gt;=7.3CI passing

Since Apr 15Pushed 9mo ago2 watchersCompare

[ Source](https://github.com/Kooser6/Session)[ Packagist](https://packagist.org/packages/kooser/session)[ Docs](https://github.com/session-lock)[ RSS](/packages/kooser-session/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (8)Versions (18)Used By (0)

Session Lock
============

[](#session-lock)

[![Continuous Integration](https://github.com/omatamix/session-lock/actions/workflows/php.yml/badge.svg)](https://github.com/omatamix/session-lock/actions/workflows/php.yml)

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

[](#installation)

The best way to install Session Lock is through composer. If you do not have composer installed you can install it directly from the [composer website](https://getcomposer.org/). After composer is successfully installed run the command line code below.

```
composer require omatamix/session-lock
```

Usage
-----

[](#usage)

### Session Manager

[](#session-manager)

The session manger comes with a simple api.

```
use Omatamix\SessionLock\SessionManager;

// Construct a new session manager.
$session = new SessionManager();
```

Start or resume a session.

```
$session->start();
```

Check to see if our session is running.

```
if ($session->exists()) {
    echo "The session is running!";
}
```

The put method sets a session variable.

```
$session->put('hello', 'world');
```

This checks to see if this session variable is set.

```
if ($session->has('hello')) {
    echo "The session variable exists.";
}
```

The delete method deletes a session variable.

```
$session->delete('hello');
```

The get method gets the session variables value.

```
echo "Hello " . $session->get('hello') . "!";
```

The flash method does the same as get but flash will delete the session variable after retrievale.

```
echo "Hello " . $session->flash('hello') . "!";
```

Stop a session.

```
$session->stop();
```

### Session Regeneration

[](#session-regeneration)

It is very easy to update the current session id with a newly generated one.

```
$session->regerate();
```

### Session Fingerprinting

[](#session-fingerprinting)

This session manager comes with a built-in session fingerprinting which in a way improves session security. When you create a session handler instance, session fingerprinting is enabled by defualt, it binds your remote ip and user agent. If you do not want this enabled you can turn it off with.

```
$session = new SessionManager([
    'fingerprinting' => false,
]);
```

You can also disable binding the remote ip or user agent like this.

```
$session = new SessionManager([
    'bind_ip_address' => false, // If set to true we will bind the ip address else dont.
    'bind_user_agent' => false, // If set to true we will bind the user agent else dont.
]);
```

If you are using a trusted proxy you can set the remote ip with this.

```
$session = new SessionManager([
    'use_ip' => '127.0.0.1',
]);
```

### Session Handlers

[](#session-handlers)

You can also set how you session information is stored using session handlers,

```
use Omatamix\SessionLock\SessionHandlers\CacheSessionHandler;

$session = new SessionManager();
$session->setSaveHandler(new CacheSessionHandler(/** A `psr/cache` or `psr/simple-cache` pool. */));
```

#### Supported

[](#supported)

- `Omatamix\SessionLock\SessionHandlers\CacheSessionHandler::class`
- `Omatamix\SessionLock\SessionHandlers\CookieSessionHandler::class`
- `Omatamix\SessionLock\SessionHandlers\DatabaseSessionHandler::class`
- `Omatamix\SessionLock\SessionHandlers\NullSessionHandler::class`

### Encryption Adapters

[](#encryption-adapters)

This library also includes encrypted session handlers.

```
use Defuse\Crypto\Key;
use Omatamix\SessionLock\Encryption\Adapter\Defuse;
use Omatamix\SessionLock\Encryption\Encrypted;

$session = new SessionManager();
$session->setSaveHandler(new Encrypeted(new CacheSessionHandler(/** A `psr/cache` or `psr/simple-cache` pool. */), new Defuse(Key::createNewRandomKey()));

// All session data will now be encrpyted using the `defuse` adapter.
```

#### Supported

[](#supported-1)

- `Omatamix\SessionLock\Encryption\Adapter\Defuse::class`
- `Omatamix\SessionLock\Encryption\Adapter\Halite::class`

### Session Config

[](#session-config)

You can also pass session configuration through the session manager constructor method.

```
$session = new SessionManager([
    'config' => [
        'use_cookies'      => true,
        'use_only_cookies' => true,
        'cookie_httponly'  => true,
        'cookie_samesite'  => 'Lax',
        'use_strict_mode'  => true,
    ]
]);
```

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

If you discover a security vulnerability within Session Lock, please send an e-mail to Nicholas via . All security vulnerabilities will be promptly addressed.

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

[](#contributing)

All contributions are welcome! If you wish to contribute.

License
-------

[](#license)

This project is licensed under the terms of the [MIT License](https://opensource.org/licenses/MIT).

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 80.8% 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 ~43 days

Recently: every ~97 days

Total

13

Last Release

2071d ago

Major Versions

v1.2.3 → v2.0.02019-08-21

v2.0.0 → v4.0.02020-01-28

v4.0.1 → v5.0.02020-08-15

### Community

Maintainers

![](https://www.gravatar.com/avatar/5e5ae2a3a1e603d2c6d2ec232f6f0d0b3106629ac0c10d802fc1c830b8bea25f?d=identicon)[Kooser6](/maintainers/Kooser6)

---

Top Contributors

[![kooser6](https://avatars.githubusercontent.com/u/48822466?v=4)](https://github.com/kooser6 "kooser6 (642 commits)")[![user-error-pixel](https://avatars.githubusercontent.com/u/47761650?v=4)](https://github.com/user-error-pixel "user-error-pixel (143 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (10 commits)")

---

Tags

cachenullphpsecuresession-fingerprintingsession-handlerssession-management

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

7310.3k29](/packages/open-dxp-opendxp)[toflar/psr6-symfony-http-cache-store

An alternative store implementation for Symfony's HttpCache reverse proxy that supports auto-pruning of expired entries and cache invalidation by tags.

574.2M13](/packages/toflar-psr6-symfony-http-cache-store)

PHPackages © 2026

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