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

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

phputil/session
===============

A simple object-oriented wrapper to PHP's session functions.

2.1.1(9y ago)6933↓33.3%LGPL-3PHPPHP &gt;=5.2.0

Since Oct 22Pushed 1y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (8)Used By (0)

Session
=======

[](#session)

PHP's session in a object-oriented version.

Main files:

- Interface [phputil\\Session](https://github.com/thiagodp/session/blob/master/lib/Session.php)
- Class [phputil\\FileBasedSession](https://github.com/thiagodp/session/blob/master/lib/FileBasedSession.php)

This project uses [semantic versioning](http://semver.org/).

### Installation

[](#installation)

```
composer require phputil/session
```

### Example 1

[](#example-1)

Setting and getting a value from the session.

```
$session = new phputil\FileBasedSession();
$session->start();

$session->put( 'user_name', $_POST[ 'user_name' ] ); // Set a value in the session
echo 'Hello, ', $session->get( 'user_name' ); // Get a value from the session
```

### Example 2

[](#example-2)

Setting session cookie name and cookie duration.

```
$session = new phputil\FileBasedSession();
$session->setName( 'myapp' ); // (optional) "PHPSESSID" session cookie key becomes "myapp"
$session->setCookieParams( $lastOneDay = 60 * 60 * 24 ); // (optional) cookie will last one day
$session->start();
```

### Example 3

[](#example-3)

Swapping between sessions.

```
$session = new phputil\FileBasedSession();

$session->start();
$savedId = $session->id();
$session->close();

// Opening another session
$session->id( $_GET[ 'another_id' ] );
$session->start(); // starts the session with id "another_id"
...
$session->close();

// Restoring the session with "savedId"
$session->id( $savedId );
$session->start();
```

### Example 4

[](#example-4)

Regenerating the session id.

```
$session = new phputil\FileBasedSession();
$session->start();
$session->regenerateId( true ); // true means delete the old file
```

### Example 5

[](#example-5)

Destroying the session.

```
$session = new phputil\FileBasedSession();
$session->start();
$session->destroy();
```

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity63

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

Recently: every ~140 days

Total

6

Last Release

3301d ago

Major Versions

1.1 → 2.02016-04-22

### Community

Maintainers

![](https://www.gravatar.com/avatar/154324d722a6ee9c252a0338329781084a97af2d0ea9faaf39176df5a689a2ec?d=identicon)[thiagodp](/maintainers/thiagodp)

---

Top Contributors

[![thiagodp](https://avatars.githubusercontent.com/u/2997844?v=4)](https://github.com/thiagodp "thiagodp (20 commits)")

---

Tags

phpphputilsessionphpsessioncookie

### Embed Badge

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

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

###  Alternatives

[marcogermani87/filament-cookie-consent

Easy cookie consent integrations for Filament

1917.0k](/packages/marcogermani87-filament-cookie-consent)[rcastera/session

Session Class

222.2k](/packages/rcastera-session)

PHPackages © 2026

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