Session variables


I need to register some extra session variables which are used in an rbac system. Where is the best place in a yii2 application to do this?? I use in the application the Yii2 advanced template?

Either in the model or controller. The logic will determine where it should be.

Thanks skworden,

I put it in the controller in the login-method, when the login is done I have the user_id. After that I can read all my roles and attached rights for the sub-systems and put the whole array in a session-variable.

you should be able to access the user like follows



Manager Docs

User Docs

I wrote my own RBAC because the Yii2 implementation did not fit the bill. I need very detailed rules per role and found the Yii way cumbersome. Also was a good exercise to get into Yii2. I come from Prado and skipped Yii1.