PHPackages                             mipotech/yii2-persistent-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. mipotech/yii2-persistent-session

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

mipotech/yii2-persistent-session
================================

A simple class for implementing persistent, server-side sessions ("server-side cookies")

1.0.3(8y ago)2100MITPHPPHP &gt;=7.0.0

Since May 16Pushed 8y ago1 watchersCompare

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

READMEChangelog (4)Dependencies (3)Versions (5)Used By (0)

Yii2 Persistent Session
=======================

[](#yii2-persistent-session)

This package provides a simple way to implement persistent sessions, otherwise known as "server-side cookies".

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

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Simply add this line:

```
"mipotech/yii2-persistent-session": "*",

```

to the `require` section of your `composer.json` file and perform a composer update.

Configuration
-------------

[](#configuration)

Add `persistentSession` as an application component in @app/config/web.php:

```
'components' => [
    ...
    'persistentSession' => [
        /* Required settings */
        'class' => 'mipotech\persistentsession\PersistentSession',

        /* Optional settings */
        //'db' => '...',            // MongoDB application component. Defaults to 'mongodb'
        //'collection' => '...',    // The name of the collection to store the session data. Defaults to 'persistent_session'
        //'cookieClass' => '...'    // The class to used to generate a new cookie. Defaults to 'yii\web\Cookie'
        //'cookieKey' => '...',     // The cookie key to use for identifying the persistent session. Defaults to 'session-id'
        //'cookieParams' => '...',  // The default cookie parameters. Defaults to ['httpOnly' => true, 'secure' => true]
        //'uniqidPrefix' => '...',  // The prefix to use for generating a new session identifier. Defaults to ''
    ]
    ...
]
```

That's it. The package is set up and ready to go.

Usage
-----

[](#usage)

The functionality of this component is intended to be as close as possible to native Yii2 sessions ([API documentation](http://www.yiiframework.com/doc-2.0/yii-web-session.html) and [user guide](http://www.yiiframework.com/doc-2.0/guide-runtime-sessions-cookies.html#sessions)).

### Opening and Closing Sessions

[](#opening-and-closing-sessions)

```
$persistentSession = Yii::$app->persistentSession;

// check if a session is already open
if ($persistentSession->isActive) ...

// open a session
$persistentSession->open();

// destroys all data registered to a session.
$persistentSession->destroy();
```

### Accessing Session Data

[](#accessing-session-data)

```
$persistentSession = Yii::$app->persistentSession;

// get a session variable.
$language = $persistentSession->get('language');

// set a session variable. The following usages are equivalent:
$persistentSession->set('language', 'en-US');

// remove a session variable. The following usages are equivalent:
$persistentSession->remove('language');

// check if a session variable exists. The following usages are equivalent:
if ($persistentSession->has('language')) ...
```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 58.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 ~117 days

Total

4

Last Release

2929d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6d1ac05bc3f037d0072843807d7fb019f475c7ebe07faec1353b071e11618cfa?d=identicon)[mipotech](/maintainers/mipotech)

---

Top Contributors

[![mipoteam](https://avatars.githubusercontent.com/u/231016014?v=4)](https://github.com/mipoteam "mipoteam (7 commits)")[![mipotech](https://avatars.githubusercontent.com/u/6897188?v=4)](https://github.com/mipotech "mipotech (5 commits)")

---

Tags

composer-packagesession-cookieyii2yii2-extensionyii2extension

### Embed Badge

![Health badge](/badges/mipotech-yii2-persistent-session/health.svg)

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

###  Alternatives

[vyants/yii2-daemon

Extension provides functionality for simple daemons creation and control

7859.0k](/packages/vyants-yii2-daemon)[dmstr/yii2-cookie-consent

Yii2 Cookie Consent Widget

1452.6k](/packages/dmstr-yii2-cookie-consent)[richardfan1126/yii2-js-register

Yii2 widget to register JS into view

1357.2k7](/packages/richardfan1126-yii2-js-register)

PHPackages © 2026

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