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

ActiveLibrary

popphp/pop-session
==================

Pop Session Component for Pop PHP Framework

4.0.4(6mo ago)312.1k↑38.9%14BSD-3-ClausePHPPHP &gt;=8.3.0CI passing

Since Jul 9Pushed 6mo ago1 watchersCompare

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

READMEChangelog (10)Dependencies (1)Versions (21)Used By (4)

pop-session
===========

[](#pop-session)

[![Build Status](https://github.com/popphp/pop-session/workflows/phpunit/badge.svg)](https://github.com/popphp/pop-session/actions)[![Coverage Status](https://camo.githubusercontent.com/2470782efcf67eb51f3a4757bdff2d607c7321b4fb0854bfcb700b6b7008f24e/687474703a2f2f63632e706f707068702e6f72672f636f7665726167652e7068703f636f6d703d706f702d73657373696f6e)](http://cc.popphp.org/pop-session/)

[![Join the chat at https://discord.gg/TZjgT74U7E](https://camo.githubusercontent.com/acad7b0eeb78b78d08ffd2b85681ab243436388b5f86f8bcb956a69246e53739/68747470733a2f2f6d656469612e706f707068702e6f72672f696d672f646973636f72642e737667)](https://discord.gg/TZjgT74U7E)

- [Overview](#overview)
- [Install](#install)
- [Quickstart](#quickstart)
- [Time-Based](#time-based)
- [Request-Based](#request-based)
- [Namespaces](#namespaces)

Overview
--------

[](#overview)

`pop-session` is a component used to manage sessions and session data in the PHP web environment. It includes the ability to also manage namespaces within the session as well as timed-based and request-based expirations.

`pop-session` is a component of the [Pop PHP Framework](https://www.popphp.org/).

[Top](#pop-session)

Install
-------

[](#install)

Install `pop-session` using Composer.

```
composer require popphp/pop-session

```

Or, require it in your composer.json file

```
"require": {
    "popphp/pop-session" : "^4.0.4"
}

```

[Top](#pop-session)

Quickstart
----------

[](#quickstart)

You can create a session and store and fetch data from it:

```
use Pop\Session\Session;

$sess = Session::getInstance();

// Set session values
$sess->foo   = 'bar';
$sess['baz'] = 123;

// Access session values
echo $sess['foo'];
echo $sess->baz;
```

You can unset session data like this:

```
unset($sess->foo);
unset($sess['baz']);
```

And finally, you can destroy the whole session like this:

```
$sess->kill();
```

[Top](#pop-session)

Time-Based
----------

[](#time-based)

Session values can be made available based on time expiration:

```
use Pop\Session\Session;

$sess = Session::getInstance();
$sess->setTimedValue('foo', 'bar', 10); // # of seconds
```

Then, the next request will be successful if it's within the time limit of that session data:

```
use Pop\Session\Session;

if (isset($sess->foo)) {
    echo $sess->foo;
} else {
    echo 'Nope!';
}
```

[Top](#pop-session)

Request-Based
-------------

[](#request-based)

Session values can be made available based on number of requests:

```
use Pop\Session\Session;

$sess = Session::getInstance();
$sess->setRequestValue('foo', 'bar', 1); // # of requests
```

Then, the next request will be successful if it's within the set limit of number requests allowed before that session data is expired:

```
if (isset($sess->foo)) {
    echo $sess->foo;
} else {
    echo 'Nope!';
}
```

[Top](#pop-session)

Namespaces
----------

[](#namespaces)

You can store session data under a namespace to separate that data from the global session data:

```
use Pop\Session\SessionNamespace;

$sessMyApp = new SessionNamespace('MyApp');
$sessMyApp->foo = 'bar'

if (isset($sessMyApp->foo)) {
    echo $sessMyApp->foo;  // Only available under the namespace.
} else {
    echo 'Nope!';
}
```

Session namespaces can also store time-based and request-based session data:

```
use Pop\Session\SessionNamespace;

$sessMyApp = new SessionNamespace('MyApp');
$sessMyApp->setTimedValue('foo', 'bar', 10); // # of seconds
$sessMyApp->setRequestValue('foo', 'bar', 1); // # of requests
```

[Top](#pop-session)

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance66

Regular maintenance activity

Popularity29

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity87

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 97.3% 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 ~226 days

Recently: every ~180 days

Total

16

Last Release

201d ago

Major Versions

3.4.1 → 4.0.02023-11-09

PHP version history (8 changes)3.0.0PHP &gt;=5.4.0

3.1.0PHP &gt;=5.6.0

3.1.4PHP &gt;=7.1.0

3.3.0PHP &gt;=7.3.0

3.4.1PHP &gt;=7.4.0

4.0.0PHP &gt;=8.1.0

4.0.1PHP &gt;=8.2.0

4.0.4PHP &gt;=8.3.0

### Community

Maintainers

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

---

Top Contributors

[![nicksagona](https://avatars.githubusercontent.com/u/898670?v=4)](https://github.com/nicksagona "nicksagona (36 commits)")[![SaphiLC](https://avatars.githubusercontent.com/u/18705494?v=4)](https://github.com/SaphiLC "SaphiLC (1 commits)")

---

Tags

phpsessionsessionspoppop php

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[popphp/pop-db

Pop Db Component for Pop PHP Framework

1814.6k11](/packages/popphp-pop-db)[popphp/pop-pdf

PHP PDF library for generating and importing PDF documents. A component of the Pop PHP Framework

207.8k1](/packages/popphp-pop-pdf)[popphp/pop-http

Pop Http Component for Pop PHP Framework

1018.5k13](/packages/popphp-pop-http)

PHPackages © 2026

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