title: How to login a user after registration in yii
body: <p>Im not sure how can I login a user right after hes creation using yii framework.</p>
  
  <p>In UserController I created the actionRegister in order to allow a user to create a new acccount, here if the user is successfully saved to db I would like to preform the login for this user aswell. Heres my code:</p>
  
  <pre><code>    public function actionRegister()
      {
          $model=new User;
  
          if(isset($_POST['User']))
          {
              $model-&gt;attributes=$_POST['User'];
  
              if($model-&gt;save()){            
  
                  $identity=new UserIdentity($model-&gt;email,$model-&gt;password);
                  $identity-&gt;authenticate();
                  Yii::app()-&gt;user-&gt;login($identity);
  
                  $this-&gt;redirect(array('view','id'=&gt;$model-&gt;id));                
              }
          }
          $this-&gt;render('register',array('model'=&gt;$model));
      }
  </code></pre>
  
  <p>Thank you in advance for any help u can give me in this matter.</p>