PHPackages                             fyre/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. [Database &amp; ORM](/categories/database)
4. /
5. fyre/session

ActiveLibrary[Database &amp; ORM](/categories/database)

fyre/session
============

A session library.

v6.0.1(9mo ago)014313MITPHP

Since Mar 26Pushed 9mo ago1 watchersCompare

[ Source](https://github.com/elusivecodes/FyreSession)[ Packagist](https://packagist.org/packages/fyre/session)[ RSS](/packages/fyre-session/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (10)Dependencies (10)Versions (31)Used By (3)

FyreSession
===========

[](#fyresession)

**FyreSession** is a free, open-source session library for *PHP*.

Table Of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Basic Usage](#basic-usage)
- [Methods](#methods)
- [Session Handlers](#session-handlers)
    - [Database](#database)
        - [MySQL](#mysql)
        - [Postgres](#postgres)
    - [File](#file)
    - [Memcached](#memcached)
    - [Redis](#redis)

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

[](#installation)

**Using Composer**

```
composer require fyre/session

```

In PHP:

```
use Fyre\Session\Session;
```

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

[](#basic-usage)

- `$container` is a [*Container*](https://github.com/elusivecodes/FyreContainer).
- `$config` is a [*Config*](https://github.com/elusivecodes/FyreConfig).

```
$session = new Session($container, $config);
```

Default configuration options will be resolved from the "*Session*" key in the [*Config*](https://github.com/elusivecodes/FyreConfig).

- `$options` is an array containing configuration options.
    - `cookie` is an array containing session cookie options.
        - `name` is a string representing the cookie name, and will default to "*FyreSession*".
        - `expires` is a number representing the cookie lifetime, and will default to 0.
        - `domain` is a string representing the cookie domain, and will default to "".
        - `path` is a string representing the cookie path, and will default to "*/*".
        - `secure` is a boolean indicating whether to set a secure cookie, and will default to *true*.
        - `sameSite` is a string representing the cookie same site, and will default to "*Lax*".
    - `expires` is a number representing the maximum lifetime of a session, and will default to the `session.gc_maxlifetime` PHP setting.
    - `path` is a string representing the session path, and will default to "*sessions*".
    - `handler`
        - `className` must be set to `\Fyre\Session\Handlers\Database\PostgresSessionHandler`.

```
$container->use(Config::class)->set('Session', $options);
```

**Autoloading**

It is recommended to bind the *Session* to the [*Container*](https://github.com/elusivecodes/FyreContainer) as a singleton.

```
$container->singleton(Session::class);
```

Any dependencies will be injected automatically when loading from the [*Container*](https://github.com/elusivecodes/FyreContainer).

```
$session = $container->use(Session::class);
```

Methods
-------

[](#methods)

**Clear**

Clear the session data.

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

**Consume**

Retrieve and delete a value from the session.

- `$key` is a string representing the session key.

```
$value = $session->consume($key);
```

**Delete**

Delete a value from the session.

- `$key` is a string representing the session key.

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

**Destroy**

Destroy the session.

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

**Get**

Retrieve a value from the session.

- `$key` is a string representing the session key.

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

**Has**

Determine whether a value exists in the session.

- `$key` is a string representing the session key.

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

**ID**

Get the session ID.

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

**Is Active**

Determine whether the session is active.

```
$isActive = $session->isActive();
```

**Refresh**

Refresh the session ID.

- `$deleteOldSession` is a boolean indicating whether to delete the old session, and will default to *false*.

```
$session->refresh($deleteOldSession);
```

**Set**

Set a session value.

- `$key` is a string representing the session key.
- `$value` is the value to set.

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

**Set Flash**

Set a session flash value.

- `$key` is a string representing the session key.
- `$value` is the value to set.

```
$session->setFlash($key, $value);
```

**Set Temp**

Set a session temporary value.

- `$key` is a string representing the session key.
- `$value` is the value to set.
- `$expire` is a number indicating the number of seconds the value will be valid, and will default to *300*.

```
$session->setTemp($key, $value, $expire);
```

**Start**

Start the session.

- `$options` is an array containing configuration options.

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

Session Handlers
----------------

[](#session-handlers)

You can load a specific session handler by specifying the `Session.handler.className` [*Config*](https://github.com/elusivecodes/FyreConfig) option.

Custom session handlers can be created by extending `\Fyre\Session\SessionHandler` and implementing the [`SessionHandlerInterface`](https://www.php.net/manual/en/class.sessionhandlerinterface.php).

### Database

[](#database)

The Database session handler can be loaded using custom configuration.

- `$options` is an array containing configuration options.
    - `className` must be set to `\Fyre\Session\Handlers\DatabaseSessionHandler`.
    - `expires` is a number representing the maximum lifetime of a session, and will default to the `session.gc_maxlifetime` PHP setting.
    - `prefix` is a string representing the session key prefix, and will default to "".
    - `connectionKey` is a string representing the *Connection* key and will default to "*default*".
    - `path` is a string representing the table name, and will default to "*sessions*".

```
$container->use(Config::class)->set('Session.handler', $options);
```

#### MySQL

[](#mysql)

The MySQL database session handler can be loaded using custom configuration.

- `$options` is an array containing configuration options.
    - `className` must be set to `\Fyre\Session\Handlers\Database\MysqlSessionHandler`.
    - `expires` is a number representing the maximum lifetime of a session, and will default to the `session.gc_maxlifetime` PHP setting.
    - `prefix` is a string representing the session key prefix, and will default to "".
    - `connectionKey` is a string representing the *Connection* key and will default to "*default*".
    - `path` is a string representing the table name, and will default to "*sessions*".

```
$container->use(Config::class)->set('Session.handler', $options);
```

#### Postgres

[](#postgres)

The Postgres database session handler can be loaded using custom configuration.

- `$options` is an array containing configuration options.
    - `className` must be set to `\Fyre\Session\Handlers\Database\PostgresSessionHandler`.
    - `expires` is a number representing the maximum lifetime of a session, and will default to the `session.gc_maxlifetime` PHP setting.
    - `prefix` is a string representing the session key prefix, and will default to "".
    - `connectionKey` is a string representing the *Connection* key and will default to "*default*".
    - `path` is a string representing the table name, and will default to "*sessions*".

```
$container->use(Config::class)->set('Session.handler', $options);
```

### File

[](#file)

The File session handler can be loaded using custom configuration.

- `$options` is an array containing configuration options.
    - `className` must be set to `\Fyre\Session\Handlers\FileSessionHandler`.
    - `expires` is a number representing the maximum lifetime of a session, and will default to the `session.gc_maxlifetime` PHP setting.
    - `prefix` is a string representing the session key prefix, and will default to "".
    - `path` is a string representing the directory path, and will default to "*sessions*".

```
$container->use(Config::class)->set('Session.handler', $options);
```

### Memcached

[](#memcached)

The Memcached session handler can be loaded using custom configuration.

- `$options` is an array containing configuration options.
    - `className` must be set to `\Fyre\Session\Handlers\MemcachedSessionHandler`.
    - `expires` is a number representing the maximum lifetime of a session, and will default to the `session.gc_maxlifetime` PHP setting.
    - `prefix` is a string representing the session key prefix, and will default to "*session:*".
    - `host` is a string representing the Memcached host, and will default to "*127.0.0.1*".
    - `port` is a number indicating the Memcached port, and will default to *11211*.
    - `weight` is a string representing the server weight, and will default to *1*.

```
$container->use(Config::class)->set('Session.handler', $options);
```

### Redis

[](#redis)

The Redis session handler can be loaded using custom configuration.

- `$options` is an array containing configuration options.
    - `className` must be set to `\Fyre\Session\Handlers\RedisSessionHandler`.
    - `expires` is a number representing the maximum lifetime of a session, and will default to the `session.gc_maxlifetime` PHP setting.
    - `prefix` is a string representing the session key prefix, and will default to "*session:*".
    - `host` is a string representing the Redis host, and will default to "*127.0.0.1*".
    - `password` is a string representing the Redis password
    - `port` is a number indicating the Redis port, and will default to *6379*.
    - `database` is a string representing the Redis database.
    - `timeout` is a number indicating the connection timeout.
    - `persist` is a boolean indicating whether to use a persistent connection, and will default to *true*.
    - `tls` is a boolean indicating whether to use a tls connection, and will default to *true*.
    - `ssl` is an array containing SSL options.
        - `key` is a string representing the path to the key file.
        - `cert` is a string representing the path to the certificate file.
        - `ca` is a string representing the path to the certificate authority file.

```
$container->use(Config::class)->set('Session.handler', $options);
```

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance58

Moderate activity, may be stable

Popularity11

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity60

Established project with proven stability

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

Recently: every ~37 days

Total

30

Last Release

275d ago

Major Versions

v1.0.4 → v2.02023-07-31

v2.0.4 → v3.02023-12-17

v3.1.1 → v4.02024-07-26

v4.0.1 → v5.02024-11-15

v5.1.8 → v6.02025-07-03

### Community

Maintainers

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

---

Top Contributors

[![elusivecodes](https://avatars.githubusercontent.com/u/18050480?v=4)](https://github.com/elusivecodes "elusivecodes (25 commits)")

---

Tags

databasememcachedmysqlphpredissession

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M87](/packages/propel-propel1)[yemenopensource/filament-excel

This package useful for importing excel files into models.

194.2k](/packages/yemenopensource-filament-excel)

PHPackages © 2026

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