$writeCallback public property
A callback that will be called during session data writing. The signature of the callback should be as follows: function ($session)
where $session is this session instance, this variable can be used to retrieve session data. Callback should return the actual fields set, which should be saved into the session storage. For example: function ($session) {
return [
'user_id' => Yii::$app->user->id,
'ip' => $_SERVER['REMOTE_ADDR'],