PHPackages                             fastpress/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. fastpress/session

ActiveLibrary[Framework](/categories/framework)

fastpress/session
=================

A robust and flexible session management library for PHP, optimized for use with the Fastpress framework. Provides secure handling of session data with an easy-to-use interface.

0.1.4(1y ago)167[1 issues](https://github.com/fastpress/session/issues)1MITPHPPHP ^7.4 || ^8.0

Since Feb 12Pushed 1y ago1 watchersCompare

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

READMEChangelogDependencies (3)Versions (6)Used By (1)

Fastpress\\Session
==================

[](#fastpresssession)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/b711ca9d15994e1d943fb25498de057d1d0f2b4345b98a1d43acf4d89c63a94a/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6661737470726573732f73657373696f6e2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d61696e)](https://scrutinizer-ci.com/g/fastpress/session/?branch=main)**Fastpress\\Session** is a modern, secure, and easy-to-use session management library for PHP. Crafted with simplicity and efficiency in mind, it seamlessly integrates with the Fastpress framework, yet remains flexible enough to be used in any PHP project. Whether you're building a small website or a large-scale application, Fastpress\\Session provides a robust solution for handling session data securely and effectively.

Features
--------

[](#features)

- **Simple and intuitive API**: Easy to use methods for session manipulation.
- **Flash messages support**: Conveniently handle one-time messages for user feedback.
- **Secure session handling**: Enhanced security features to prevent common vulnerabilities.
- **Flexible configuration**: Customize session behavior to fit your application's needs.
- **PSR-4 autoloading**: Fully compliant with modern PHP standards.

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

[](#installation)

Use Composer to install Fastpress\\Session into your project:

```
composer require fastpress/session
```

Requirements
------------

[](#requirements)

- PHP 7.4 or higher.

Usage
-----

[](#usage)

### `start(): bool`

[](#start-bool)

Starts the session.

**Returns:**

- `true` if the session was started successfully, `false` otherwise.

### `regenerateId(bool $deleteOldSession = true): bool`

[](#regenerateidbool-deleteoldsession--true-bool)

Regenerates the session ID.

**Parameters:**

- `$deleteOldSession`: Whether to delete the old session data.

**Returns:**

- `true` on success, throws `RuntimeException` on failure.

### `token(): string`

[](#token-string)

Generates a CSRF token.

**Returns:**

- The generated CSRF token.

### `validateToken(string $token): bool`

[](#validatetokenstring-token-bool)

Validates a CSRF token.

**Parameters:**

- `$token`: The token to validate.

**Returns:**

- `true` if the token is valid, `false` otherwise.

### `setFlash(string $key, mixed $value, string $type = 'info'): void`

[](#setflashstring-key-mixed-value-string-type--info-void)

Sets a flash message.

**Parameters:**

- `$key`: The key for the flash message.
- `$value`: The value of the flash message.
- `$type`: The type of flash message (e.g., 'info', 'success', 'error').

**Returns:**

- `void`

### `getFlash(string $key, mixed $default = null): mixed`

[](#getflashstring-key-mixed-default--null-mixed)

Gets a flash message.

**Parameters:**

- `$key`: The key for the flash message.
- `$default`: The default value to return if the flash message does not exist.

**Returns:**

- The flash message value or the default value.

### `closeWrite(): bool`

[](#closewrite-bool)

Closes the session for writing.

**Returns:**

- `true` on success, `false` otherwise.

### `gc(bool $force = false): bool`

[](#gcbool-force--false-bool)

Performs garbage collection on the session.

**Parameters:**

- `$force`: Whether to force garbage collection.

**Returns:**

- `true` on success, `false` otherwise.

### `destroy(): void`

[](#destroy-void)

Destroys the session.

**Returns:**

- `void`

### `set(string $key, mixed $value): void`

[](#setstring-key-mixed-value-void)

Sets a session variable.

**Parameters:**

- `$key`: The key for the session variable.
- `$value`: The value of the session variable.

**Returns:**

- `void`

### `get(string $key, mixed $default = null): mixed`

[](#getstring-key-mixed-default--null-mixed)

Gets a session variable.

**Parameters:**

- `$key`: The key for the session variable.
- `$default`: The default value to return if the session variable does not exist.

**Returns:**

- The session variable value or the default value.

### `has(string $key): bool`

[](#hasstring-key-bool)

Checks if a session variable exists.

**Parameters:**

- `$key`: The key for the session variable.

**Returns:**

- `true` if the session variable exists, `false` otherwise.

### `delete(string $key): void`

[](#deletestring-key-void)

Deletes a session variable.

**Parameters:**

- `$key`: The key for the session variable.

**Returns:**

- `void`

### `clear(): void`

[](#clear-void)

Clears all session variables.

**Returns:**

- `void`

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity40

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

Total

5

Last Release

518d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8224efc6c85f9ed635239195b886766f000c05d279ba93124dcc361c235efdf7?d=identicon)[samayo](/maintainers/samayo)

---

Top Contributors

[![samayo](https://avatars.githubusercontent.com/u/5304093?v=4)](https://github.com/samayo "samayo (10 commits)")

---

Tags

phpframeworksecuritysessionsession-managementfastpress

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

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

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

PHPackages © 2026

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