2017 © Pedro Peláez
 

yii2-extension yii2-redis-session

Yii2 session based on Redis, can separate session by user

image

bscheshirwork/yii2-redis-session

Yii2 session based on Redis, can separate session by user

  • Tuesday, January 30, 2018
  • by bscheshirwork
  • Repository
  • 2 Watchers
  • 5 Stars
  • 1,752 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 0 Open issues
  • 1 Versions
  • 37 % Grown

The README.md

yii2-redis-session

Based on yii2-redis session. Can remove user's sessions by user identity id. Can get a online users., (*1)

Redis Session implements a session component using redis as the storage medium., (*2)

Redis Session requires redis version 3.0.2 or higher to work properly., (*3)

It needs to be configured with a redis [[Connection]] that is also configured as an application component., (*4)

By default it will use the redis application component (see yii2-redis for more info)., (*5)

[
    'components' => [
        'redis' => [
            'class' => 'yii\redis\Connection',
            'hostname' => 'localhost',
            'port' => 6379,
            'database' => 0,
        ],
    ]
]

To use redis Session as the session application component, configure the application as follows,, (*6)

[
   'components' => [
       'session' => [
           'class' => 'bscheshirwork\redis\Session',
           // 'redis' => 'redis' // id of the connection application component
       ],
   ],
]

Installation

Add, (*7)

    "bscheshirwork/yii2-redis-session": "*@dev",

into your composer.json require section., (*8)

Functional

Get all online user's, (*9)

\Yii::$app->session->getOnlineUsers();

Get all active session by user, (*10)

\Yii::$app->session->getSessionsById($userIdentityId);

Remove all active session by user, (*11)

\Yii::$app->session->destroyUserSessions($userIdentityId);

Get all active sessions, (*12)

\Yii::$app->session->getActiveSessions();

Tests

See this (ru) guide for create PHPUnit suite, (*13)

The Versions

30/01 2018

dev-master

9999999-dev

Yii2 session based on Redis, can separate session by user

  Sources   Download

BSD-3-Clause

The Requires

 

redis yii session