douqian2334
2014-08-01 09:45
浏览 273
已采纳

Yii2登录 Yii :: $ app-> user-> login($ user,0)不保存

I am trying implement login at my site. But seems like Yii::$app->user->login($user, 0) doesn't save identity.

When I've just logged in it work fine:

    if (Yii::$app->user->login($user, 0) ) {
        var_dump(Yii::$app->user->identity);
    } else {
        echo 'didnt login';
    }

var_dump() show identity.

But when I am trying obtain identity in another controller var_dump() shows NULL:

// In other controller
var_dump(Yii::$app->user->identity);

Does somebody know about this problem?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题