dev-master
9999999-devYii2 session based on Redis, can separate session by user
BSD-3-Clause
The Requires
- yiisoft/yii2-redis *
- php >=7.1.0
redis yii session
Yii2 session based on Redis, can separate session by user
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 ], ], ]
Add, (*7)
"bscheshirwork/yii2-redis-session": "*@dev",
into your composer.json
require
section., (*8)
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();
See this (ru) guide for create PHPUnit suite, (*13)
Yii2 session based on Redis, can separate session by user
BSD-3-Clause
redis yii session