Hi,
I have just uploaded my Yii Project to my new Hosting Service.
Everything ok, except for one strange problem.
I have a database with two users and both works very well on the local machine.
But in the hosting server if i try to login with a user something dont work, is like that someone do an immediate logout.
Example:
- Normal case:
I request a protected action on my controller, that only registered user can see.
Yii show to me the login form, that i fill and submit.
If correct it show me the previous requested page.
- My Case:
I request a protected action on my controller, that only registered user can see.
Yii show to me the login form, that i fill and submit.
If correct, it send me to the index page (like if i have requested a logout)
And if i request the protected page again it show me the login page again. (so im not authenticated)
Note: If i check RememberMe it send me to the index page too, but if i’ll require the requested page another time, it show me (like if i was logged succesful). But in this case commands like
Yii::app()->session['variable']
dont work
Someone can help me in this? Anyone has an idea?
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));
}