Search code examples
phpyiiyii-extensions

Yii-user AfterLogin callback


I am using the Yii-user module in my project, and I wonder if there is some "afterLogin" callback I can use to run some code of my own (By now I just need to add a couple of variables to the session) if the user is correctly authenticated.


Solution

  • Try this

     public function actionLogin(){
        //all your stuff for login action
        //after validated login
        if(Yii::app()->user->id){
             $this->addVariablesToSession($param);
        }
     }
    

    Add this function in the same controller This store as many variables in session after successful login.

     public function addVariablesToSession($param){
          Yii:app()->session["variable_name"] = $param;
     }