Q:

Yii 2 session initialize

Hi guys implementing the yii2 advanced template and not being able to initialize session variables . Im trying to do it when the log in is success.
Anyone have any example on how to do it?
This how im trying to do it in the backend (its a snippet of the success login function):
foreach($data as $newInfo) {
        $session = Yii::$app->session;
        $session->open();
        $session['nombre'] = $newInfo['nombre'];
        $session['email'] = $newInfo['email'];

}

A:

You should do this way ..
use  yii\web\Session;

$session = Yii::$app->session;
$session->open();

foreach($data as $newInfo) {
   $session->set('nombre', $newInfo['nombre']);
   $session->set('email', $newInfo['email']);

}

and could be useful this brief doc http://www.bsourcecode.com/yiiframework2/session-handling-in-yii-framework-2-0/

