Loging In Is Not Working On Hosting


I have made a new web application using yii freamework and test it locally on my machine (ubuntu) and everything worked as expected.

but when i uploded it to shared hosting I faced a [size="2"] real weird problem with useridentity .[/size]

After logging in with the right username and password the login form returns me to the index page with no error beside that the Yii::app()->user->isGuest =true which means that the user is not logged in.

[size="2"]here is the code of [/size][size="3"]protected/components/UserIdentity.php[/size]


 [/size]class UserIdentity extends CUserIdentity {

    private $_id;

    private $_username;

    private $_isAdmin = true;


 	* Authenticates a user.

 	* The example implementation makes sure if the username and password

 	* are both 'demo'.

 	* In practical applications, this should be changed to authenticate

 	* against some persistent user identity storage (e.g. database).

 	* @return boolean whether authentication succeeds.


    public function authenticate() {

        $user = User::model()->findByAttributes(array('username' => $this->username));

        if ($user === NULL) {

            $this->errorCode = self::ERROR_USERNAME_INVALID;

        } elseif ($user->password !== $this->password) {

            $this->errorCode = self::ERROR_PASSWORD_INVALID;

        } else {

            $this->errorCode = self::ERROR_NONE;

            $this->setState('role', $user->role);

            $this->_id = $user->user_id;

            $this->_username = $user->username;

            $this->_isAdmin = TRUE;

            if ($user->role == 'admin') {

                $this->setState('isAdmin', TRUE);

            } else {

                $this->setState('isAdmin', FALSE);



        return !$this->errorCode;


    public function getId() {

        return $this->_id;


    public function getUsername() {

        return $this->_username;




[size="3"]as you can see in the authenticate method, [/size]

[size="3"]also I uploaded a fresh copy of web-application generated with yiic to test the login but it did work either. same problem occurred after logining in with (user:admin & password:admin ) no username where displayed instead of login item in the menu bar,[/size]

[size="3"]can any body help with this issue,

[/size]thanks in advanced,

It might be worth checking that the session cookie is being set in a browser cookie (if cookie based sessions are enabled) after trying to log in you should see a cookie for the domain called PHPSESSID or the URL should have the session ID added on to it if neither of these is happening then the session isn’t being stored and the log in won’t be remembered

Thanks kes3, your reply is really appreciated

Actually after I posted this topic I found that the problem is related to the Session and exactly that the session path in php.ini was not correct.

After I fix the session path, the problem is solved.