PHP code example of vaszloy / yii2-redis-session

1. Go to this page and download the library: Download vaszloy/yii2-redis-session library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

vaszloy / yii2-redis-session example snippets


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

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

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

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

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

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