With Yii 2.0.6 we have the new functionality to store data in an extra column in sessiontable when using database.
http://www.yiiframework.com/doc-2.0/yii-web-multifieldsession.html
'session' => [
'class' => 'yii\web\DbSession',
'sessionTable' => '{{%session}}',
'readCallback' => function ($fields) {
return [
'expireDate' => Yii::$app->formatter->asDate($fields['expire']),
];
},
'writeCallback' => function ($session) {
return [
'session_idp' => null,
'user_id' => Yii::$app->user->id,
];
}
],
The code above saves the id of the user in a new column in the sessiontable.
My question is: how can I set these attributes somewhere else. My goal is to set the session_idp in a controller as I will get this value from an external source. I also want to be able to clear the session data of all rows that has a given value in session_idp -column.
Does anyone know how to use this new functionality for what I want?
Or is it only possible to modify this value in the config-files?
My idea right now is to create a session-model that will handle this for me, but I am guessing there is a better way of doing this as of version 2.0.6?