return to previous URL after logging out

Hello,

I’ve tried setting returnUrl in many ways including defining it in main layout like bellow but no matter what I do atfer logging out depending on what browser I use it returns to either home page, 404 or for some weird reason tries to load favicon.ico

this is what I’ve tried:


Yii::app()->user->setReturnUrl($_SERVER['REQUEST_URI']);

or

Yii::app()->user->setReturnUrl($model->url);

and in the logout controller, after logging the user out, I’ve tried to execute following codes


$this->controller->refresh();

or

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

Reason why I want to return to the previous/current page after logging-out is because I’ve implemented xPortlet and I have login box on header layout viewable site-wide, login works fine since it refreshes the page, but the same refresh code for logout results in infinite loop

Any help would be appreciated

Try this,


$this->redirect(Yii::app()->request->urlReferrer);

request->urlReferrer Works like a charm

Thank you, much appreciated :)