dbsession in module adm

Hi fellas,

I need to insert especific table dbsession for a especific admin module,but I can not.

The code below generates duplicity in the two tables session_user and session_adm.


'session' => [


            'class' => 'yii\web\DbSession',

            'sessionTable' => 'vvr_user_session',

             'writeCallback' => function ($session) {

                    return [

                       'id_user' => (Yii::$app->user->isGuest)?0:Yii::$app->user->id,

                       'last_write' => date('Y-m-d H:i:s'),



            'timeout'=> 60*30            


module admin:

Yii::$app->session->sessionTable = 'vvr_adm_session';

      Yii::$app->session->writeCallback = function($session){

        return [

                        'id_adm' => (Yii::$app->user->isGuest)?0:Yii::$app->user->id,

                        'last_write' => date('Y-m-d H:i:s'),



Yii::$app->session->timeout= 60*60; 

Just a thought. In Yii2 you can set up more than one db component in the config files. Is it possible to set up two session components? Then somehow change the @app->session component from session to sessionAdmin.

I can to replace my session of the Authentication when i request my module.

This function work, but set my session db session_user and set my db session_adm.

I have identified that the writeCallback function is responsible for this.

Because the session is executed before the init ().

Then my user_id in web.php receive my id_adm, Being a security problem.