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

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

krubio/perfect-session
======================

Session Handling

v0.1.2(3mo ago)02.7k1MITPHPPHP &gt;=8.0.0CI passing

Since Sep 21Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/benanamen/perfect-session)[ Packagist](https://packagist.org/packages/krubio/perfect-session)[ RSS](/packages/krubio-perfect-session/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (8)Versions (4)Used By (1)

[![codecov](https://camo.githubusercontent.com/11bf296aa3609448ad3094a8e2c2eafe9d9565c2ff1cf79fc8613aeb44c50ca0/68747470733a2f2f636f6465636f762e696f2f67682f62656e616e616d656e2f706572666563742d73657373696f6e2f6272616e63682f6d61737465722f67726170682f62616467652e7376673f746f6b656e3d35305349577254664e47)](https://codecov.io/gh/benanamen/perfect-session)[![CodeFactor](https://camo.githubusercontent.com/65a47ac34de3bf9bef8661a13c41255485c234f5aaddc2208a72d6a13a9e9875/68747470733a2f2f7777772e636f6465666163746f722e696f2f7265706f7369746f72792f6769746875622f62656e616e616d656e2f706572666563742d73657373696f6e2f6261646765)](https://www.codefactor.io/repository/github/benanamen/perfect-session)[![codebeat badge](https://camo.githubusercontent.com/29bd5d0395c46d7e1cd9f6fb821a6d141c5bf6be32080fad708eb7217b1a3cbb/68747470733a2f2f636f6465626561742e636f2f6261646765732f63376565306432352d313262372d343631622d383763662d346239393765643262383932)](https://codebeat.co/projects/github-com-benanamen-perfect-session-master)[![Maintainability](https://camo.githubusercontent.com/298e9a0bafd0aea150b701cfc56855d68811dcb7fb38256c4ff7bc742dcb007d/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f31343964303839663863336637666230613436302f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/benanamen/perfect-session/maintainability)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/ba3bd3b59d86faf469aec3e0b866544dff1e6939e70dcae41f4ae937478a7b39/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f62656e616e616d656e2f706572666563742d73657373696f6e2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/benanamen/perfect-session/?branch=master)[![Build Status](https://camo.githubusercontent.com/62f3c608dffc070da6a49f1809565375f3188ec556b545b8b05fd7d3c8f59149/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f62656e616e616d656e2f706572666563742d73657373696f6e2f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/benanamen/perfect-session/build-status/master)[![Code Intelligence Status](https://camo.githubusercontent.com/6fbfe11b6e2d5663fddd4fde5542c79ea42c17a194f35dc2a7976d69b27fde18/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f62656e616e616d656e2f706572666563742d73657373696f6e2f6261646765732f636f64652d696e74656c6c6967656e63652e7376673f623d6d6173746572)](https://scrutinizer-ci.com/code-intelligence)

[![Bugs](https://camo.githubusercontent.com/92d3198bb50aa817a1454758219ec53a3ccd87f103ab823f2b73a0f0c1ea51dc/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d62656e616e616d656e5f706572666563742d73657373696f6e266d65747269633d62756773)](https://sonarcloud.io/summary/new_code?id=benanamen_perfect-session)[![Security Rating](https://camo.githubusercontent.com/6b81b69ebdd36a21ebcb7450e2536af250ef5ed7f5e64301d9c371b31fff348b/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d62656e616e616d656e5f706572666563742d73657373696f6e266d65747269633d73656375726974795f726174696e67)](https://sonarcloud.io/summary/new_code?id=benanamen_perfect-session)[![Maintainability Rating](https://camo.githubusercontent.com/567013d9d6124731ac45200f9f55bb4a6392218b15708b30bcf4a4904a9885c7/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d62656e616e616d656e5f706572666563742d73657373696f6e266d65747269633d7371616c655f726174696e67)](https://sonarcloud.io/summary/new_code?id=benanamen_perfect-session)[![Vulnerabilities](https://camo.githubusercontent.com/d66b5dab41dfb205479801578145c95b56cba9c7a7ccee3098000ea54eff49c0/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d62656e616e616d656e5f706572666563742d73657373696f6e266d65747269633d76756c6e65726162696c6974696573)](https://sonarcloud.io/summary/new_code?id=benanamen_perfect-session)[![Quality Gate Status](https://camo.githubusercontent.com/e2575678927dbfcfd2434ee3ae95299da9e7f0c988c73747f1a3ffb1b8b6f680/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d62656e616e616d656e5f706572666563742d73657373696f6e266d65747269633d616c6572745f737461747573)](https://sonarcloud.io/summary/new_code?id=benanamen_perfect-session)[![Duplicated Lines (%)](https://camo.githubusercontent.com/5064651a0b9d69ac67d0016b2f26ee1060cec8ed2376776ecbac4dd3501800c6/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d62656e616e616d656e5f706572666563742d73657373696f6e266d65747269633d6475706c6963617465645f6c696e65735f64656e73697479)](https://sonarcloud.io/summary/new_code?id=benanamen_perfect-session)[![Technical Debt](https://camo.githubusercontent.com/3abf24f4d0dff37b3745ea6408e5dbdee0f791225eb955363124651c24486f17/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d62656e616e616d656e5f706572666563742d73657373696f6e266d65747269633d7371616c655f696e646578)](https://sonarcloud.io/summary/new_code?id=benanamen_perfect-session)[![Code Smells](https://camo.githubusercontent.com/6251073dcbfc5f1c552c051ad83182553954da45f6e33eef6a9721d824fc03ba/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d62656e616e616d656e5f706572666563742d73657373696f6e266d65747269633d636f64655f736d656c6c73)](https://sonarcloud.io/summary/new_code?id=benanamen_perfect-session)[![Reliability Rating](https://camo.githubusercontent.com/ce1b2805236896c9745fc962763c24b2d1eb403a4c4f95dab136fee34aea93d4/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d62656e616e616d656e5f706572666563742d73657373696f6e266d65747269633d72656c696162696c6974795f726174696e67)](https://sonarcloud.io/summary/new_code?id=benanamen_perfect-session)

Session Class
=============

[](#session-class)

The` Session` class provides a simple and convenient way to manage PHP sessions.

Usage
-----

[](#usage)

To use the `Session` class, create an instance of it and call its methods to get, set, or delete session data.

```
use PerfectApp\Session\Session;

// Create a new session object
$session = new Session();

// Set a session variable
$session->set('username', 'johndoe');

// Get a session variable
$username = $session->get('username');

// Delete a session variable
$session->delete('username');
```

By default, the `Session` class uses the` $_SESSION` superglobal to store session data. You can also pass an array of session data to the constructor if you want to use a different session data source.

```
// Create a session object using a custom session data array
$sessionData = [
    'username' => 'johndoe',
    'email' => 'johndoe@example.com',
];

$session = new Session($sessionData);

// Get a session variable
$username = $session->get('username');

// Delete a session variable
$session->delete('username');
```

Methods
-------

[](#methods)

`__construct(array|null $sessionData = null)`

Creates a new `Session` object.

### Parameters

[](#parameters)

- `$sessionData` (optional): An array of session data to use instead of `$_SESSION`.

`get(string $key): mixed|null`

Gets a session variable by key.

### Parameters

[](#parameters-1)

- `$key`: The name of the session variable to get.

### Returns

[](#returns)

The value of the session variable, or `null` if the variable does not exist.

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

Sets a session variable by key.

### Parameters

[](#parameters-2)

- `$key`: The name of the session variable to set.
- `$value`: The value to assign to the session variable.

`delete(string $key): void`

Deletes a session variable by key.

### Parameters

[](#parameters-3)

- `$key`: The name of the session variable to delete.

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance81

Actively maintained with recent releases

Popularity22

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity41

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

Total

3

Last Release

100d ago

### Community

Maintainers

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

---

Top Contributors

[![benanamen](https://avatars.githubusercontent.com/u/1039435?v=4)](https://github.com/benanamen "benanamen (12 commits)")

---

Tags

sessionsessions

###  Code Quality

TestsCodeception

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[deptrac/deptrac

Deptrac is a static code analysis tool that helps to enforce rules for dependencies between software layers.

3.0k8.8M118](/packages/deptrac-deptrac)[laminas/laminas-session

Object-oriented interface to PHP sessions and storage

8524.2M132](/packages/laminas-laminas-session)[ticketswap/phpstan-error-formatter

A minimalistic error formatter for PHPStan

87718.9k56](/packages/ticketswap-phpstan-error-formatter)[ec-europa/toolkit

Toolkit packaged for Drupal projects based on Robo.

40252.8k34](/packages/ec-europa-toolkit)[ergebnis/rector-rules

Provides rules for rector/rector.

10245.6k52](/packages/ergebnis-rector-rules)[lipemat/phpstan-wordpress

Phpstan extension for working with WordPress

1462.8k1](/packages/lipemat-phpstan-wordpress)

PHPackages © 2026

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