Hi, im newbie with yii framework. Im trying to make a login function. When user input user and pass, it must direct from site/login to main/index and still keep the log-in status. But I dont know how to do it, please help.
Hi, im newbie with yii framework. Im trying to make a login function. When user input user and pass, it must direct from site/login to main/index and still keep the log-in status. But I dont know how to do it, please help.
http://www.yiiframework.com/forum/index.php/topic/35495-login/page__view__findpost__p__170552
If you look at this login action:
public function actionLogin()
{
$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));
}
You can change: $this->redirect(Yii::app()->user->returnUrl); to: $this->redirect(controller/action)
It help me a lot, thank