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

ActiveLibrary

maer/session
============

A dead simple and basic session library

1.0.0(10y ago)172MITPHPPHP &gt;=5.4.0

Since Nov 17Pushed 10y ago1 watchersCompare

[ Source](https://github.com/magnus-eriksson/session)[ Packagist](https://packagist.org/packages/maer/session)[ RSS](/packages/maer-session/feed)WikiDiscussions develop Synced 2mo ago

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

A dead simple session library in PHP
====================================

[](#a-dead-simple-session-library-in-php)

[![Build Status](https://camo.githubusercontent.com/5239b93f2190bbe2deac3ae08142f297ca3ca4085954ed71b72f3618d7a9b19a/68747470733a2f2f6170692e7472617669732d63692e6f72672f6d61676e75732d6572696b73736f6e2f73657373696f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/magnus-eriksson/session)

Manage PHP sessions and flash sessions in a simple way.

Install
-------

[](#install)

Clone this repository or use composer to download the library with the following command:

```
composer require maer/session 1.*

```

Set up
------

[](#set-up)

Load the library via composers autoloader:

```
include '/path/to/vendor/autoload.php';

```

Load the library manually:

```
include '/path/to/library/src/SessionInterface.php';
include '/path/to/library/src/Session.php';

```

Example
-------

[](#example)

When a session instance is created, it will check if the session already is started. If not, it will start it using `session_start()`.

### Managing sessions

[](#managing-sessions)

```
$session = new Maer\Session\Session();

// Set a value
$session->set('my-key', 'my-value');

// Get a value
$value = $session->get('my-key');

// Add an optional second argument
$value = $session->get('non-existint-key', 'this-will-be-returned');

// Check if a key exists
if ($session->has('my-key')) {
    // Yay... it exists!
} else {
   // Darn! It didn't exist!
}

// Forget/clear/remove a session key
$session->forget('my-key');

// Forget/clear/remove all session keys and destroy the session cookie
$session->destroy();

```

### Flash sessions

[](#flash-sessions)

A flash session is a "one-request-only"-session. If you set a flash session, it is only accessable in the next request and will then be removed. It's perfect for things like success/status/error messages.

```
// Set a flash session
$session->setFlash('error', 'This is an error message');

// On the next request
$value = $session->getFlash('error');

// Add an optional second argument
$value = $session->get('non-existint-key', 'this-will-be-returned');

```

Both `->get(...)` and `->getFlash(...)` returns `NULL` as default if the key isn't found.

---

I told you it was dead simple!

If you have any questions, suggestions or issues, let me know!

Happy coding!

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

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

Unknown

Total

1

Last Release

3831d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1ada6171adca1bf89432dd54fff188ef3d890a71734278bd06b54487f45b5695?d=identicon)[maer](/maintainers/maer)

---

Top Contributors

[![magnus-eriksson](https://avatars.githubusercontent.com/u/3640297?v=4)](https://github.com/magnus-eriksson "magnus-eriksson (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

PHPackages © 2026

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