Hello guys I have this code in main.php config file:
'components' => array(
'[.........]',
'user'=>array(
// enable cookie-based authentication
'allowAutoLogin'=>true,
'autoRenewCookie' => true,
'returnUrl' => 'http://stackoverflow.com',
)
);
My problem is that id doesn’t redirects user to http://stackoverflow.com after login, can you please help me?
UserController.php :
public function actionLogin()
{
if (!Yii::app()->user->isGuest){
$this->redirect('/user/index');
return;
}
$model=new LoginForm;
// if it is ajax validation request
if(isset($_POST['ajax']) && $_POST['ajax']==='login-form')
{
echo CActiveForm::validate($model);
Yii::app()->end();
}
// collect user input data
if(isset($_POST['LoginForm']))
{
$model->attributes=$_POST['LoginForm'];
// validate user input and redirect to the previous page if valid
if($model->validate() && $model->login())
$this->redirect(Yii::app()->user->returnUrl);
}
// display the login form
$this->render('login',array('model'=>$model));
}
I have found a solution for my problem. I added this lines of code in login.php so after user login it will redirect on previous page: