propelera
(Propelera)
March 8, 2012, 10:45am
1
I am using Yii framework and I want to use user setstate, getstate methods but found out some problems, please can you help me to solve them? here is my codes:
UserIdentity.php
protected function afterLogin()
{
Yii::app()->user->setState('username', $record->username);
Yii::app()->user->setState('privilages', $record->privilages);
}
man layout
array('label'=>Yii::app()->user->getState('username'), 'url'=>array('/user/index'), 'visible'=>!Yii::app()->user->isGuest),
when user loges in it doesn’t show his username, it just show whitespaces. so can you tell me what is wrong with it?
mbi
(mbi)
March 8, 2012, 10:55am
2
how to authenticate against database and setting the username, you can see here
http://blog.mbischof.de/gegen-db-authentifizieren
however, $record is not available in your afterLogin-method
propelera:
I am using Yii framework and I want to use user setstate, getstate methods but found out some problems, please can you help me to solve them? here is my codes:
UserIdentity.php
protected function afterLogin()
{
Yii::app()->user->setState('username', $record->username);
Yii::app()->user->setState('privilages', $record->privilages);
}
man layout
array('label'=>Yii::app()->user->getState('username'), 'url'=>array('/user/index'), 'visible'=>!Yii::app()->user->isGuest),
when user loges in it doesn’t show his username, it just show whitespaces. so can you tell me what is wrong with it?
Try this:
man layout
array('label'=>Yii::app()->user->username, 'url'=>array('/user/index'), 'visible'=>!Yii::app()->user->isGuest),
Change from Yii::app()->user->getState(' username’) to Yii::app()->user->username
Remove what is in bold.
the function afterLogin know which is the variable $record? I dont see this in parameters. If this is global you need is $this->record
salmaHabib
(Salma0692)
October 25, 2017, 11:32am
5
Hello,
Can anyone explain how we can use it? /How to use it, I do not understand, confused.
Thnx.
tri
(tri - Tommy Riboe)
October 25, 2017, 12:18pm
6