2017 © Pedro Peláez
 

yii2-extension yii2-persistent-session

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

image

mipotech/yii2-persistent-session

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

  • Wednesday, May 2, 2018
  • by mipotech
  • Repository
  • 1 Watchers
  • 2 Stars
  • 39 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 18 % Grown

The README.md

Yii2 Persistent Session

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

Installation

The preferred way to install this extension is through composer., (*2)

Simply add this line:, (*3)

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

to the require section of your composer.json file and perform a composer update., (*4)

Configuration

Add persistentSession as an application component in @app/config/web.php:, (*5)

'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., (*6)

Usage

The functionality of this component is intended to be as close as possible to native Yii2 sessions (API documentation and user guide)., (*7)

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

$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')) ...

The Versions

02/05 2018

dev-master

9999999-dev

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

  Sources   Download

MIT

The Requires

 

by Chaim Leichman, MIPO Technologies Ltd

extension yii2

02/05 2018

1.0.3

1.0.3.0

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

  Sources   Download

MIT

The Requires

 

by Chaim Leichman, MIPO Technologies Ltd

extension yii2

15/03 2018

1.0.2

1.0.2.0

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

  Sources   Download

MIT

The Requires

 

by Chaim Leichman, MIPO Technologies Ltd

extension yii2

23/01 2018

1.0.1

1.0.1.0

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

  Sources   Download

MIT

The Requires

 

by Chaim Leichman, MIPO Technologies Ltd

extension yii2

16/05 2017

1.0.0

1.0.0.0

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

  Sources   Download

MIT

The Requires

 

by Chaim Leichman, MIPO Technologies Ltd

extension yii2