2017-04-17 16:05:58 4114次浏览 2条回答 0 悬赏 15 金钱

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
    (
    )

)

补充于 2017-04-17 16:31

恩恩,登录了

补充于 2017-04-17 16:31

确定登录了

最佳答案

  • johnny1991 发布于 2017-04-17 16:52 举报

    吧你这个类common\models\register\LoginUser里面定义的$username,这个属性去掉,自定义的属性和数据库里面的字段重复了

    1 条回复
    回复于 2017-04-17 18:02 回复

    原来是这样,现在好了,谢谢啊

    觉得很赞
您需要登录后才可以回答。登录 | 立即注册
this_summer
主管

this_summer 北京

注册时间:2017-04-07
最后登录:2023-06-25
在线时长:14小时55分
  • 粉丝2
  • 金钱630
  • 威望0
  • 积分770

热门问题