PHPackages                             neoflow/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. [Framework](/categories/framework)
4. /
5. neoflow/session

Abandoned → [odan/session](/?search=odan%2Fsession)ArchivedLibrary[Framework](/categories/framework)

neoflow/session
===============

Session service for Slim 4 and similar PSR-15 compliant frameworks and apps.

2.1.0(4y ago)89691MITPHPPHP &gt;=7.3

Since Jul 11Pushed 2y ago1 watchersCompare

[ Source](https://github.com/jnessier/Session)[ Packagist](https://packagist.org/packages/neoflow/session)[ RSS](/packages/neoflow-session/feed)WikiDiscussions master Synced 1w ago

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

This project is no longer maintained.
=====================================

[](#this-project-is-no-longer-maintained)

Please use other solutions for session handling on PHP.

---

Session
=======

[](#session)

[![Build Status](https://camo.githubusercontent.com/c39b5c06b465d9b09646b210142f6adadf9f97e6e5c9931ebaed5b57585e64c6/68747470733a2f2f7472617669732d63692e6f72672f4e656f666c6f772f53657373696f6e2e7376673f6272616e63683d6d617374657226736572766963653d676974687562)](https://travis-ci.org/Neoflow/Session)[![Coverage Status](https://camo.githubusercontent.com/5ed6784323acaf8086ee514edef66ef8d30c42b11659714f6b06f6689030a689/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f4e656f666c6f772f53657373696f6e2f62616467652e7376673f6272616e63683d6d617374657226736572766963653d676974687562)](https://coveralls.io/github/Neoflow/Session?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/d07db947bb540f6808e8674e0eb0d393e6908fa921cc8f32a24cd4e8327d4303/68747470733a2f2f706f7365722e707567782e6f72672f6e656f666c6f772f73657373696f6e2f763f736572766963653d676974687562)](https://packagist.org/packages/neoflow/session)[![Total Downloads](https://camo.githubusercontent.com/b8ad3ff49388aab89a6a3ef9c2ab627db631752cdd9bd2d23f3a6373e6feb192/68747470733a2f2f706f7365722e707567782e6f72672f6e656f666c6f772f73657373696f6e2f646f776e6c6f6164733f736572766963653d676974687562)](//packagist.org/packages/neoflow/session)[![License](https://camo.githubusercontent.com/665dd8215a72cbaf6fb1a1d15a92af8cc7cadc446b0a7cb67f93549138316493/68747470733a2f2f706f7365722e707567782e6f72672f6e656f666c6f772f73657373696f6e2f6c6963656e73653f736572766963653d676974687562)](https://packagist.org/packages/neoflow/session)

Session service for Slim 4 and similar [PSR-15](https://www.php-fig.org/psr/psr-15/) compliant frameworks and apps.

Table of Contents
-----------------

[](#table-of-contents)

- [Requirement](#requirement)
- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
- [Flash messages](#flash-messages)
- [Contributors](#contributors)
- [History](#history)
- [License](#license)

Requirement
-----------

[](#requirement)

- PHP &gt;= 7.3

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

[](#installation)

You have 2 options to install this library.

Via composer...

```
composer require neoflow/session
```

...or manually download the latest release from [here](https://github.com/Neoflow/Session/releases/).

Configuration
-------------

[](#configuration)

The following instructions based on [Slim 4](http://www.slimframework.com), in combination with [PHP-DI](https://php-di.org), but should be adaptable for any PSR-11/PSR-15 compliant frameworks and libraries.

Add the service `Neoflow\Session\Session` and middleware `Neoflow\Session\Middleware\SessionMiddleware`to the container definitions...

```
use Neoflow\Session\Session;
use Neoflow\Session\SessionInterface;
use Neoflow\Session\Middleware\SessionMiddleware;
use Psr\Container\ContainerInterface;

return [
    // ...
    SessionInterface::class => function () {
        return new Session([ // Default session options
            'name' => 'sid',
            'autoRefresh' => true,
            'cookie' => [
                'lifetime' => 3600,
                'path' => '/',
                'domain' => null,
                'secure' => false,
                'httponly' => true,
                'samesite' => 'Lax'
            ],
            'iniSettings' => []
        ]);
    },
    SessionMiddleware::class => function (ContainerInterface $container) {
        $session = $container->get(SessionInterface::class);
        return new SessionMiddleware($session);
    },
    // ...
];
```

...and register the middleware, to autostart the session when it got dispatched.

```
use Neoflow\Session\Middleware\SessionMiddleware;

$app->add(SessionMiddleware::class);
```

The service `Neoflow\Session\Session` supports the following options:

KeyTypeDescriptionDefault`name`stringName of the session cookie.`"sid"``autoRefresh`boolRefresh of session lifetime after each request.`true``cookie['lifetime']`intLifetime in seconds of the session cookie in seconds`3600``cookie['path']`stringPath to set in the session cookie`"/"``cookie['domain']`string/nullDomain to set in the session cookie`null``cookie['secure']`boolSet `true` to sent session cookie only over secure connections`false``cookie['httponly']`boolSet `false` to make session cookie accessible for scripting languages`true``cookie['samesite']`stringSet `"Strict"` to prevent the session cookie be sent along with cross-site requests`"Lax"``iniSettings[]`array[PHP session settings](https://www.php.net/manual/en/session.configuration.php), without `session.``[]`When your DI container supports inflectors (e.g. [league/container](https://container.thephpleague.com/3.x/inflectors/)), you can optionally register `Neoflow/Session/SessionAwareInterface` as inflector to your container definition.

Additionally, you can also use `Neoflow/Session/SessionAwareTrait` as a shorthand implementation of `Neoflow/Session/SessionAwareInterface`.

Usage
-----

[](#usage)

Examples how to handle the session:

```
// Set session name.
$name = 'sid'; // Session name
$session = $session->setName($name);

// Set session cookie.
$session = $session->setCookie([
    // Cookie options
]);

// Start session.
$started = $session->start();

// Get session status.
$status = $session->getStatus();

// Check whether session is started.
$isStarted = $session->isStarted();

// Generate new session id.
$id = $session->generateId();

// Get session cookie.
$cookie = $session->getCookie();

// Get session id.
$id = $session->getId();

// Get session name.
$name = $session->getName();

// Destroy session.
$destroyed = $session->destroy();
```

Examples how to access and manage the values of the session:

```
// Get session value by key.
$default = null; // Default value, when key doesn't exists
$value = $session->getValue('key', $default);

// Set session value by key.
$overwrite = true; // Set FALSE to prevent overwrite existing value
$session = $session->setValue('key', 'value', $overwrite);

// Check whether session value exists by key.
$valueExists = $session->hasValue('key');

// Delete session value by key.
$session->deleteValue('key');

// Count number of session values.
$numberOfValues = $session->countValues();

// Get session values.
$values = $session->getValues();

// Clear session values.
$session = $session->clearValues();

// Replace session values by key. Existing values with similar keys will be overwritten.
$recursive = true; // Set TRUE to enable recursive replacement
$session = $session->replaceValues([
    // Array with key/value pairs
], $recursive);

// Set session values. Existing values will be overwritten.
$session = $session->setValues([
    // Array with key/value pairs
]);
```

Flash messages
--------------

[](#flash-messages)

The first version of this library had built-in support for flash messages. But to comply with the design principle of separation of concerns, the code of the flash messages was move into a standalone library, called [Neoflow\\FlashMessages](https://github.com/Neoflow/FlashMessages).

If you need support for flash messages, you can easily combine both libraries as composer packages. The integration and usage of [Neoflow\\FlashMessages](https://github.com/Neoflow/FlashMessages) is very similar to the current library.

Contributors
------------

[](#contributors)

- Jonathan Nessier, [Neoflow](https://www.neoflow.ch)

If you would like to see this library develop further, or if you want to support me or show me your appreciation, please donate any amount through PayPal. Thank you! 🍻

[![Donate](https://camo.githubusercontent.com/80602243714763ba4467ec539f09f678d206cc112e76d358bf8970c5c90c2b7b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f6e6174652d70617970616c2d626c7565)](https://www.paypal.me/JonathanNessier)

License
-------

[](#license)

Licensed under [MIT](LICENSE).

*Made in Switzerland with 🧀 and ❤️*

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity56

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

Recently: every ~126 days

Total

9

Last Release

1614d ago

Major Versions

1.1.0 → 2.0.02020-08-07

PHP version history (3 changes)1.0.0-betaPHP ^7.2

2.0.0PHP ^7.3

2.1.0PHP &gt;=7.3

### Community

Maintainers

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

---

Top Contributors

[![odan](https://avatars.githubusercontent.com/u/781074?v=4)](https://github.com/odan "odan (3 commits)")

---

Tags

middlewarephp73psr-11psr-15sessionsession-serviceslimslim-frameworkslim4

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[laravel/passport

Laravel Passport provides OAuth2 server support to Laravel.

3.4k85.0M532](/packages/laravel-passport)[nolimits4web/swiper

Most modern mobile touch slider and framework with hardware accelerated transitions

41.8k177.2k1](/packages/nolimits4web-swiper)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k36.7M259](/packages/laravel-dusk)[laravel/prompts

Add beautiful and user-friendly forms to your command-line applications.

712181.8M596](/packages/laravel-prompts)[cakephp/chronos

A simple API extension for DateTime.

1.4k47.7M121](/packages/cakephp-chronos)[laravel/pail

Easily delve into your Laravel application's log files directly from the command line.

91545.3M590](/packages/laravel-pail)

PHPackages © 2026

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