How to Redirect User to Previous Page on Successful Login?

Hi,

My UserController.php has the following logic in place to check if the user authenticates via the model:


if($model->login())

	$this->redirect(Yii::app()->user->returnUrl);

However, I can’t determine if and where returnUrl has been defined. Where should it be defined and what is the appropriate syntax to send the user to the previous page upon successful login?

Yii::app()->user->returnUrl; is set in loginRequired() method. Please read the docs/code (following the link provided) - I hope after that you’ll be able to handle your case.