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

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

folded/session
==============

Session manipulation utlilities for your web app.

v0.2.2(5y ago)1151MITPHPPHP &gt;=7.4.0

Since Sep 14Pushed 5y ago2 watchersCompare

[ Source](https://github.com/folded-php/session)[ Packagist](https://packagist.org/packages/folded/session)[ RSS](/packages/folded-session/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependencies (4)Versions (6)Used By (0)

folded/session
==============

[](#foldedsession)

Session manipulation utilities for your web app.

[![Packagist License](https://camo.githubusercontent.com/6c5cb9f123a57c7b193c222c4856c5066f67188b72f27ab86236dd1ab4e85a23/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f666f6c6465642f73657373696f6e)](https://github.com/folded-php/session/blob/master/LICENSE) [![Packagist PHP Version Support](https://camo.githubusercontent.com/ee74549bfdef78b78577e11af78a1566cbe039c2ce83a9e734d9f818422c8b5f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f666f6c6465642f73657373696f6e)](https://github.com/folded-php/session/blob/master/composer.json#L14) [![Packagist Version](https://camo.githubusercontent.com/0b185f70e0d5681e3a4327e10ebff27ffe78067c746b9cec08ab516c65d02f6f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f666f6c6465642f73657373696f6e)](https://packagist.org/packages/folded/session) [![Build Status](https://camo.githubusercontent.com/618168c23b41d205abcd3da22656376f8e1abb3b565bde6875f7dd29d8466d08/68747470733a2f2f7472617669732d63692e636f6d2f666f6c6465642d7068702f73657373696f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/folded-php/session) [![Maintainability](https://camo.githubusercontent.com/d0c5443963794df6db24f391c3510dbae8438003762a75097afe7b0f75353ca0/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f30626261393963663263666339373538396461622f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/folded-php/session/maintainability) [![TODOs](https://camo.githubusercontent.com/141e75b227935e64629dcec31b06260135a92e2c05899f4863cb5d9d1e004294/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d68747470733a2f2f6170692e7469636b6769742e636f6d2f62616467653f7265706f3d6769746875622e636f6d2f666f6c6465642d7068702f73657373696f6e)](https://www.tickgit.com/browse?repo=github.com/folded-php/session)

Summary
-------

[](#summary)

- [About](#about)
- [Features](#features)
- [Requirements](#requirements)
- [Installation](#installation)
- [Examples](#examples)
- [Version support](#version-support)

About
-----

[](#about)

I created this library to be able to manipulate a session, e.g. setting and getting data, checking if a data is present, ... In a standalone way.

Folded is a constellation of packages to help you setting up a web app easily, using ready to plug in packages.

- [folded/action](https://github.com/folded-php/action): A way to organize your controllers for your web app.
- [folded/config](https://github.com/folded-php/config): Configuration utilities for your PHP web app.
- [folded/crypt](https://github.com/folded-php/crypt): Encrypt and decrypt strings for your web app.
- [folded/exception](https://github.com/folded-php/exception): Various kind of exception to throw for your web app.
- [folded/history](https://github.com/folded-php/history): Manipulate the browser history for your web app.
- [folded/http](https://github.com/folded-php/http): HTTP utilities for your web app.
- [folded/orm](https://github.com/folded-php/orm): An ORM for you web app.
- [folded/request](https://github.com/folded-php/request): Request utilities, including a request validator, for your PHP web app.
- [folded/routing](https://github.com/folded-php/routing): Routing functions for your PHP web app.
- [folded/view](https://github.com/folded-php/view): View utilities for your PHP web app.

Features
--------

[](#features)

- Set and get value by keys
- Can flash value (which means they can be getted only once)
- Can remove values by key
- Can check if a value exist by its key
- Uses the plain `$_SESSION` superglobal

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

[](#requirements)

- PHP version &gt;= 7.4.0
- Composer installed

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

[](#installation)

- [1. Install the package](#1-install-the-package)
- [2. Add the setup code](#2-add-the-setup-code)

### 1. Install the package

[](#1-install-the-package)

In your root folder, run this command:

```
composer require folded/session
```

### 2. Add the setup code

[](#2-add-the-setup-code)

In the script you want to use, call for the session start function:

```
if (session_status() !== PHP_SESSION_ACTIVE) {
  session_start();
}

// ...
```

Examples
--------

[](#examples)

- [1. Set a value](#1-set-a-value)
- [2. Get a value by key](#2-get-a-value-by-key)
- [3. Check if a value exist by key](#3-check-if-a-value-exist-by-key)
- [4. Flash a value](#4-flash-a-value)
- [5. Keep a value one more time after being flashed](#5-keep-a-value-one-more-time-after-being-flashed)
- [6. Remove a value by key](#6-remove-a-value-by-key)

### 1. Set a value

[](#1-set-a-value)

In this example, we will set the value in the session.

```
use function Folded\setSession;

setSession("token", "12345");
```

### 2. Get a value by key

[](#2-get-a-value-by-key)

In this example, we will get the value of a session key.

```
use function Folded\setSession;
use function Folded\getSession;

setSession("token", "12345");

echo getSession("token"); // "12345"
```

### 3. Check if a value exist by key

[](#3-check-if-a-value-exist-by-key)

In this example, we will check if a value exist by its key.

```
use function Folded\hasSession;

if (hasSession("token")) {
  echo "has token in session";
} else {
  echo "has not token in session yet";
}
```

### 4. Flash a value

[](#4-flash-a-value)

Flashing a value consist of telling the session to keep a value for a single usage. In this example, we will set a flash value, then get it once. Any attempt to get it a second time will fail.

```
use function Folded\flashSession;
use function Folded\getSession;
use function Folded\hasSession;

flashSession("token", "12345");

echo getSession("token"); // "12345"

var_dump(hasSession("token")); // bool(false)
```

### 5. Keep a value one more time after being flashed

[](#5-keep-a-value-one-more-time-after-being-flashed)

In this example, we will use the second parameter of `getSession()` to keep a flashed data one last time after being getted.

```
use function Folded\getSession;
use function Folded\flashSession;
use function Folded\hasSession;

flashSession("token", "12345");

getSession("token", $keep = true);

var_dump(hasSession("token")); // bool(true)
```

### 6. Remove a value by key

[](#6-remove-a-value-by-key)

In this example, we will set a value, then remove it, and check if it exist.

```
use function Folded\hasSession;
use function Folded\removeSession;
use function Folded\setSession;

setSession("token", "12345");

var_dump(hasSession("token")); // booll(true)

removeSession("token");

var_dump(hasSession("token")); // bool(false)
```

Version support
---------------

[](#version-support)

7.37.48.0v0.1.0❌✔️❓v0.1.1❌✔️❓v0.2.0❌✔️❓v0.2.1❌✔️❓v0.2.2❌✔️❓

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity48

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

Total

5

Last Release

2052d ago

### Community

Maintainers

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

---

Top Contributors

[![khalyomede](https://avatars.githubusercontent.com/u/15908747?v=4)](https://github.com/khalyomede "khalyomede (24 commits)")

---

Tags

flashphpsession

###  Code Quality

TestsPest

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[knplabs/knp-menu-bundle

This bundle provides an integration of the KnpMenu library

1.4k53.8M315](/packages/knplabs-knp-menu-bundle)[lipis/flag-icons

A curated collection of all country flags in SVG — plus the CSS for easier integration.

12.0k27.5k4](/packages/lipis-flag-icons)[graphp/graphviz

GraphViz graph drawing for the mathematical graph/network library GraPHP.

3232.1M49](/packages/graphp-graphviz)[davidpiesse/nova-map

Map field for Laravel Nova

114224.3k](/packages/davidpiesse-nova-map)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)[php-mp4box/php-mp4box

PHP MP4Box, an Object Oriented library for easy file conversion with MP4 Box

16217.3k1](/packages/php-mp4box-php-mp4box)

PHPackages © 2026

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