Return to last URL entered after successfull login in Yii
... Controller extends CController (){
...
public function init() {
if($this->isValidForRedirectRequest(Yii::app()->request)){
Yii::app()->user->returnUrl = Yii::app()->request->requestUri;
}
}
...
public function isValidForRedirectRequest(){
/*something validations of request, like isAjax or other */
}
}...
... LoginController()...{
if($authIdentity->authenticate()) $this->redirect(Yii::app()->user->returnUrl);
...
}
I think this will work:
Yii::app()->user->setReturnUrl("Your url");
then use,
$this->redirect(Yii::app()->user->returnUrl);
to redirect.
or you can also take help of session.
before login set
Yii::app()->session['beforelogin'] = Yii::app()->request->requestUri;`
just before redirecting after login check
if(isset(Yii::app()->session['beforelogin'])) {
$this->redirect(Yii::app()->session['beforelogin']);
}