Property "User.salt" is not defined.

here the error message i get:



Property "User.salt" is not defined.

Source File


00095: */

00096: public function __get($name)

00097: {

00098: if(isset($this->_attributes[$name]))

00099: return $this->_attributes[$name];

00100: else if(isset($this->getMetaData()->columns[$name]))

00101: return null;

00102: else if(isset($this->_related[$name]))

00103: return $this->_related[$name];

00104: else if(isset($this->getMetaData()->relations[$name]))

00105: return $this->getRelated($name);

00106: else

00107: return parent::__get($name);

00108: }


00110: /**

00111: * PHP setter magic method.

00112: * This method is overridden so that AR attributes can be accessed like properties.

00113: * @param string property name

00114: * @param mixed property value

00115: */

00116: public function __set($name,$value)

00117: {

00118: if($this->setAttribute($name,$value)===false)

00119: {

Stack Trace

#0 C:\wamp\www\yii\framework\db\ar\CActiveRecord.php(107): CComponent->__get(‘salt’)

#1 C:\wamp\www\blog\protected\models\User.php(101): CActiveRecord->__get(‘salt’)

#2 C:\wamp\www\blog\protected\components\UserIdentity.php(18): User->validatePassword(‘demo’)

#3 C:\wamp\www\blog\protected\models\LoginForm.php(52): UserIdentity->authenticate()

#4 C:\wamp\www\yii\framework\validators\CInlineValidator.php(39): LoginForm->authenticate(‘password’, Array)

#5 C:\wamp\www\yii\framework\validators\CValidator.php(176): CInlineValidator->validateAttribute(Object(LoginForm), ‘password’)

#6 C:\wamp\www\yii\framework\base\CModel.php(150): CValidator->validate(Object(LoginForm), NULL)

#7 C:\wamp\www\blog\protected\controllers\SiteController.php(88): CModel->validate()

#8 C:\wamp\www\yii\framework\web\actions\CInlineAction.php(32): SiteController->actionLogin()

#9 C:\wamp\www\yii\framework\web\CController.php(300): CInlineAction->run()

#10 C:\wamp\www\yii\framework\web\CController.php(278): CController->runAction(Object(CInlineAction))

#11 C:\wamp\www\yii\framework\web\CController.php(257): CController->runActionWithFilters(Object(CInlineAction), Array)

#12 C:\wamp\www\yii\framework\web\CWebApplication.php(320): CController->run(‘login’)

#13 C:\wamp\www\yii\framework\web\CWebApplication.php(120): CWebApplication->runController(‘site/login’)

#14 C:\wamp\www\yii\framework\base\CApplication.php(135): CWebApplication->processRequest()

#15 C:\wamp\www\blog\index.php(12): CApplication->run()

#16 {main}

2010-03-20 13:35:57 Apache/2.2.11 (Win32) PHP/5.2.9-1 Yii Framework/1.1.1

You are trying to use the “salt” field but there isn’t any “salt” field for your model class


Ekerazha is correct, you need to add the attribute into your model.


public $salt;


Abovie is an insanely basic example, but give it a whirl. Post your model/User.php file if you still are having issues.

cheers to you quick support guys…got hold of the problem now. I AM LOVING THIS NEW YII BABY

Yap, the above field definition works. I just used it in my app and was able to resolve this problem. Thanks guys.

ys that ture this working well

hello there !

I got the same problem. I tried to practice of making blog from tutotial. I recived message ‘Property “User.salt” is not defined’. I added field public $salt; into class User, then i couldn’t logged in, message: Incorrect username or password.

Blog should has authentification: demo, demo (from database). I used schema.mysql from demo/blog.


Please reference, if it helps, please leave your footprints



The salt HAS to be in the User table and set in create user. That way when the user logs in the hash will always have the same salt value to add to the password to get the correct match value.