Query Regarding Useridentity Errormessage

The errorMessage constant is always empty and not showing any value while errorCode is set at some non-zero value.

Please check the posting guidelines - http://www.yiiframework.com/forum/index.php/topic/19451-guidelines-for-posting-this-forum/

If you want proper help you need to explain your problem better.

I believe you are thinking on this property - http://www.yiiframework.com/doc/api/1.1/CBaseUserIdentity#errorMessage-detail

If so, that property gets populated by the validation. So you need to check your validation rules.

With the help of Authentication and Authorization guide I have changed my code as below…


class AuthController extends CController {


	public function actionAjaxLogin() {

		if(Yii::app()->request->isAjaxRequest) {

			$username = $_POST['username'];

			$userpass = $_POST['userpass'];

			$identity = new UserIdentity($username, $userpass);


			if($identity->authenticate()) {



			else {		

				echo $identity->errorMessage;



		else {

			echo "No access";





Authentication method of UserIdentity class is changed like this…

public function authenticate() {

		$record = GblUserList::model()->findByAttributes(array('username'=>$this->username));



		else if($record->password!==md5($this->password))


        	else {


	            $this->setState('title', $record->title);



        	return !$this->errorCode;	


Problem is $identity->errorMessage is not printing error message in my controller while there is certain error code.

Problem is $identity->errorMessage is not printing error message

It defaults to empty, you should set it in authenticate() like you do with errorCode.

Guide probably has an error.