PHPackages                             pollen-solutions/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. [HTTP &amp; Networking](/categories/http)
4. /
5. pollen-solutions/session

ActiveLibrary[HTTP &amp; Networking](/categories/http)

pollen-solutions/session
========================

Pollen Solutions - Session Component - HTTP Request User's session store and query information.

v1.0.0(4y ago)03921MITPHPPHP ^7.4 || ^8.0

Since Aug 13Pushed 4y ago1 watchersCompare

[ Source](https://github.com/pollen-solutions/session)[ Packagist](https://packagist.org/packages/pollen-solutions/session)[ Docs](https://www.presstify.com/pollen-solutions/session/)[ RSS](/packages/pollen-solutions-session/feed)WikiDiscussions master Synced 5d ago

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

Session Component
=================

[](#session-component)

[![Latest Stable Version](https://camo.githubusercontent.com/449540d9aec38e93835e61c36bc734f45a34fe63384cdae9882610d2be07084a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f706f6c6c656e2d736f6c7574696f6e732f73657373696f6e2e7376673f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/pollen-solutions/session)[![MIT Licensed](https://camo.githubusercontent.com/daa52099573be5a50c320c4387496400f2f722e49f86a42db8d5778130d3582d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e3f7374796c653d666f722d7468652d6261646765)](LICENSE.md)[![PHP Supported Versions](https://camo.githubusercontent.com/d9d71d0b69072c51e1ff7adfdb6270f896f75787500ce6437120e23727c081d1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d2533453d372e342d3838393242463f7374796c653d666f722d7468652d6261646765266c6f676f3d706870)](https://www.php.net/supported-versions.php)

Pollen Solutions **Session** Component provides utilities to store and query informations through HTTP Request User's session.

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

[](#installation)

```
composer require pollen-solutions/session
```

Basic Usage
-----------

[](#basic-usage)

```
use Pollen\Session\SessionManager;

$session = new SessionManager();
try {
    $session->start();
} catch (RuntimeException $e) {
    unset($e);
}

$session->set('key1', 'value1');
$session->set('key2', 'value2');

var_dump($session->all());
```

Base General API
----------------

[](#base-general-api)

```
use Pollen\Session\SessionManager;

$session = new SessionManager();

// Start session (with exception catching for best practice).
try {
    $session->start();
} catch (RuntimeException $e) {
    // throwing error.
    throw $e;
    // or mute the error.
    // unset($e);
}

// Sets data.
$session->set('key1', 'value1');
$session->set('key2', 'value2');

// Checks if data key exists.
$session->has('key1');

// Gets data value.
$session->get('key1', 'defaultValue');

// Returns all data values.
$session->all();

// Counts datas.
$session->count();

// Deletes a data by its key.
$session->remove('key1');

// Clear all existing datas.
$session->clear();
```

Base Flash API
--------------

[](#base-flash-api)

A simple way to set flash messages in an HTTP request and to display them after a page redirect.

```
use Pollen\Session\SessionManager;

$session = new SessionManager();

try {
    $session->start();
} catch (RuntimeException $e) {
    unset($e);
}

// Retrieve the flashBag instance.
$session->flash();

// Sets a flash data.
$session->flash()->set('key1', 'value1');
$session->flash()->set('key2', 'value2');

// Alternative method to set flash data.
$session->flash([
    'key1' => 'value1',
    'key2' => 'value2'
]);

// Checks if flash data exists by its key.
$session->flash()->has('key1');

// Gets a flash data value without removing it.
$session->flash()->peek('key1');

// Gets a flash data value with a fallback value and without removing it.
$session->flash()->read('key1', 'defaultValue1');

// Gets all flash data values.
$session->flash()->peekAll();

// Alternative method to gets all flash data values
$session->flash()->readAll();

// Gets a flash data value and removing it.
$session->flash()->get('key1');

// Gets a flash data value with a fallback value and removing it.
$session->flash('key1', 'defaultValue');

// Gets all flash data value and removing them.
$session->flash()->all();

// Counts flash datas.
$session->flash()->count();

// Removes a flash data by its key.
$session->flash()->remove('key1');

// Clear all flash datas.
$session->flash()->clear();
```

CSRF Protection
---------------

[](#csrf-protection)

Session provides a protection system against CSRF attacks.

### Set Token ID

[](#set-token-id)

Ideally, use a string of at least 32 characters.

```
use Pollen\Session\SessionManager;

$session = new SessionManager();
$session->setTokenID('example_token_id');
```

### Basic token verification process

[](#basic-token-verification-process)

```
use Pollen\Session\SessionManager;

$session = new SessionManager();
$session->setTokenID('example_token_id');

$token = $session->getToken();

var_dump($session->verifyToken($token));
```

### Custom token verification process

[](#custom-token-verification-process)

```
use Pollen\Session\SessionManager;

$session = new SessionManager();

$token = $session->getToken('custom_token_id');

var_dump($session->verifyToken($token, 'custom_token_id'));
```

### Form workflow

[](#form-workflow)

1. Create a CSRF token.

```
use Pollen\Session\SessionManager;

$session = new SessionManager();

$csrf_token = $session->getToken();
```

2. Submit a form with CSRF token.

```

    Submit

```

3. Catch and verify CSRF token submission.

```
use Pollen\Session\SessionManager;
use Pollen\Http\Request;

$session = new SessionManager();
$request = Request::createFromGlobals();
$token = $request->request->get('token');

var_dump($session->verifyToken($token));
```

Advanced usage
--------------

[](#advanced-usage)

### Access to the session through an HTTP Request

[](#access-to-the-session-through-an-http-request)

```
use Pollen\Session\SessionManager;
use Pollen\Http\Request;

$session = new SessionManager();
try {
    $session->start();
} catch (RuntimeException $e) {
    unset($e);
}

$session->set('key1', 'value1');
$session->set('key2', 'value2');

$request = Request::createFromGlobals();
$request->setSession($session->processor());

var_dump($request->getSession()->all());
```

### Attribute Key Bag

[](#attribute-key-bag)

```
use Pollen\Session\SessionManager;

$session = new SessionManager();
try {
    $session->start();
} catch (RuntimeException $e) {
    unset($e);
}

// Registers an attribute key bag.
$keyBag = $session->addAttributeKeyBag('specialKey');

// Sets data for key
$keyBag->set('test1', 'value1');
$keyBag->set('test2', 'value2');

// Alternate dot syntax allowed
$keyBag->set('test3.childs', ['child1', 'child2', 'child3']);

// Get data
var_dump($keyBag->all());
var_dump($session->get('specialKey'));
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community9

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

Unknown

Total

1

Last Release

1738d ago

### Community

Maintainers

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

---

Top Contributors

[![jordy-manner](https://avatars.githubusercontent.com/u/733356?v=4)](https://github.com/jordy-manner "jordy-manner (1 commits)")

---

Tags

httpsessioncomponentpollen-solutions

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[nette/http

🌐 Nette Http: abstraction for HTTP request, response and session. Provides careful data sanitization and utility for URL and cookies manipulation.

48619.2M541](/packages/nette-http)[aplus/app

Aplus Framework App Project

5951.6M1](/packages/aplus-app)[kdyby/fake-session

FakeSession class for Nette Framework

11354.8k7](/packages/kdyby-fake-session)[mrclay/shibalike

Provides a PHP library for emulating a Shibboleth environment.

2060.5k7](/packages/mrclay-shibalike)[middlewares/php-session

Middleware to start php sessions using the request data

1525.8k3](/packages/middlewares-php-session)[chelout/laravel-http-logger

A Laravel package to log HTTP requests, headers and sessions

272.0k](/packages/chelout-laravel-http-logger)

PHPackages © 2026

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