Yii::$app->user->identity不能获取用户数据 [ 2.0 版本 ]
Yii::$app->user->identity->username获取数据,显示为空,var_dump(ii::$app->user->identity)
common\models\register\LoginUser Object
(
[username] =>
[password] =>
[rememberMe] => 1
[_user:common\models\register\LoginUser:private] =>
[_attributes:yii\db\BaseActiveRecord:private] => Array
(
[id] => 1
[username] => xiaoqiang
[password] =>
[phone] => 18094570201
[ip] =>
[status] => 10
[password_hash] => $2y$13$MPXhbqGADeuHLI6L.ld0vOy6KNoP0MDMty/8qUZf5kY.oh0X0Rqk2
[auth_key] =>
[created] => 0000-00-00 00:00:00
)
[_oldAttributes:yii\db\BaseActiveRecord:private] => Array
(
[id] => 1
[username] => xiaoqiang
[password] =>
[phone] => 18094570201
[ip] =>
[status] => 10
[password_hash] => $2y$13$MPXhbqGADeuHLI6L.ld0vOy6KNoP0MDMty/8qUZf5kY.oh0X0Rqk2
[auth_key] =>
[created] => 0000-00-00 00:00:00
)
[_related:yii\db\BaseActiveRecord:private] => Array
(
)
[_errors:yii\base\Model:private] =>
[_validators:yii\base\Model:private] =>
[_scenario:yii\base\Model:private] => default
[_events:yii\base\Component:private] => Array
(
)
[_behaviors:yii\base\Component:private] => Array
(
)
)
this_summer 补充于 2017-04-17 16:31
恩恩,登录了
this_summer 补充于 2017-04-17 16:31
确定登录了
最佳答案
-
johnny1991 发布于 2017-04-17 16:52 举报
吧你这个类common\models\register\LoginUser里面定义的$username,这个属性去掉,自定义的属性和数据库里面的字段重复了
共 1 条回复this_summer 回复于 2017-04-17 18:02 回复原来是这样,现在好了,谢谢啊
this_summer 觉得很赞
其他 1 个回答
-
dashixiong 回答于 2017-04-17 16:26 举报
你确定你处于登录状态?
this_summer 北京
注册时间:2017-04-07
最后登录:2023-06-25
在线时长:14小时55分
最后登录:2023-06-25
在线时长:14小时55分
- 粉丝2
- 金钱630
- 威望0
- 积分770