Tutorial by Examples

import Session Class use yii\web\Session; Create a session $session = Yii::$app->session; $session->open(); // open a session $session->close(); // close a session Store the value in session variable. $session = Yii::$app->session; $session->set('name', 'stack'); OR ...
Save the session variable as a variable. $session = Yii::$app->session; $sess = $session['keys']; Then create or update the array value you want $sess['first'] = 'abc'; And finally save to the session variable $session['keys'] = $sess
Use case: remember the current URL to return to after adding a new record in a different (related) controller, for instance create a new contact to add to an invoice being edited. InvoiceController / actionUpdate: Url::remember(Url::current(), 'returnInvoice'); ContactController / actionCreate:...

Page 1 of 1