PHPackages                             phico/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. phico/session

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

phico/session
=============

Specialised session support for Phico

v0.1.0(1y ago)016BSD-3-ClausePHPPHP ^8.0

Since Jul 5Pushed 1y agoCompare

[ Source](https://github.com/phico-php/session)[ Packagist](https://packagist.org/packages/phico/session)[ RSS](/packages/phico-session/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

Session
=======

[](#session)

Specialised session support for [Phico](https://github.com/phico-php/phico)

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

[](#installation)

Install using composer

```
composer require phico/session
```

Config
------

[](#config)

Session config should be passed as an array

```
$config = [

    // set the cookie parameters
    'cookie' => [

        'name' => 'ssn',

        'options' => [
            'expires' => 0,
            'path' => '/',
            'domain' => '',
            'secure' => false,
            'httponly' => true,
            'samesite' => 'Lax',
            'prefix' => '',
            'encode' => false,
        ],

    ],

    // set the Time To Live in seconds, sessions will expire after this time
    'ttl' => 3600
];
```

Usage
-----

[](#usage)

### Instantiating the Session

[](#instantiating-the-session)

Use the session middleware to pass the session through the Request.

```
public function use(): array
{
    return [
        \Phico\Session\SessionMiddleware::class
    ]
}
```

### Storing Data

[](#storing-data)

To store data in the session, use the `set` method.

```
$session->set('key', 'value');

// or shorthand
$session->key = $value;
```

### Retrieving Data

[](#retrieving-data)

To retrieve data from the session, use the `get` method. You can provide a default value that will be returned if the key does not exist.

```
$value = $session->get('key');

// optionally specify a default value if key is not in the session
$value = $session->get('key', 'default');

// or shorthand without specifying a default
$value = $session->key;
```

### Checking for Data

[](#checking-for-data)

To check if a key exists in the session, use the `has` method.

```
$exists = $session->has('key');
```

### Flash Messages

[](#flash-messages)

Flash messages are used to store data that should be available for only the next request.

#### Setting Flash Messages

[](#setting-flash-messages)

```
$session->flash('flash_key', 'flash_value');
```

#### Retrieving Flash Messages

[](#retrieving-flash-messages)

Flash messages are retrieved using the same `get` method.

```
$flashValue = $session->get('flash_key');
```

### Deleting the Session

[](#deleting-the-session)

To delete a session, use the `delete` method. This removes the session data from the storage.

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

### Accessing the Session ID

[](#accessing-the-session-id)

THe session id is readonly

```
$id = $session->id;
```

### Regenerating the Session ID

[](#regenerating-the-session-id)

To create a new session id use the `regenerate` method, this will remove the old session from storage.

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

Issues
------

[](#issues)

If you discover any bugs or issues in behaviour or performance please create an issue, and if you are able a pull request with a fix.

Please make sure to update any tests as appropriate.

For major changes, please open an issue first to discuss what you would like to change.

License
-------

[](#license)

[BSD-3-Clause](https://choosealicense.com/licenses/bsd-3-clause/)

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 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

683d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/65541311?v=4)[indgy](/maintainers/indgy)[@indgy](https://github.com/indgy)

---

Top Contributors

[![indgy](https://avatars.githubusercontent.com/u/65541311?v=4)](https://github.com/indgy "indgy (36 commits)")

###  Code Quality

TestsPest

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

PHPackages © 2026

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