user directly access a secure page through bookmark or history. he is then redirected to the login page. I am trying to redirect user to referral url after successfully logged in. but the Yii::app()->user->returnUrl returns index.php/account/favicon.ico.
Yii::app()->request->urlReferrer return null.
I’ve gone through many posts which discusses Yii::app()->user->returnUrl and Yii::app()->request->urlReferrer
AccountController extends CController
the secure page for eg index.php/user/dashboard userController extends CController
components/controller.php:
<?php
public function beforeAction($action)
{
if( Yii::app()->user->isGuest )
{
Yii::app()->user->setReturnUrl(Yii::app()->request->getUrl());
$this->redirect(array('account/login'));
}
}
?>
controllers/AccountController.php
<?php
class AccountController extends CController
{
public $layout = 'login_layout';
public function actionLogin()
{
$this->render( '/login/loginform',array( 'model'=>$model ) );
}
?>
views/login/loginform.php
<?php
echo "parent.location.href = '" . Yii::app()->user->returnUrl . "'";
?>