In the controller of login(actionLogin) i have created session & on successful login i have set session variables & rendered the page dashboard.
In the dashboard i have tried echoing that session variable in the layout of main.php which is my menubar.
<?php echo $session['name']; ?>
I have opened the session in the menubar as
<body>
<?php $this->beginBody() ?>
<?php $session->open();?>
it is showing me error that calling to non-object method open.
I have also added use yii\web\session on the top.
How to access the session in the layout