Skip to content

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

Notifications You must be signed in to change notification settings

bscheshirwork/yii2-redis-session

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yii2-redis-session

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

Redis Session implements a session component using redis as the storage medium.

Redis Session requires redis version 3.0.2 or higher to work properly.

It needs to be configured with a redis [[Connection]] that is also configured as an application component.

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

[
    '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,

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

Installation

Add

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

into your composer.json require section.

Functional

Get all online user's

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

Get all active session by user

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

Remove all active session by user

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

Get all active sessions

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

Tests

See this (ru) guide for create PHPUnit suite

About

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages