Authentication 成功登录后,用户不会登录到YII2前端

Authentication 成功登录后,用户不会登录到YII2前端,authentication,login,yii2,Authentication,Login,Yii2,如果我运行登录功能,它将打印用户 public function actionLogin(){ if ($model->load(Yii::$app->request->post()) && $model->login()) { if (Yii::$app->user->isGuest) { echo "guest"; } else { echo "User"; } return

如果我运行登录功能,它将打印
用户

public function actionLogin(){
if ($model->load(Yii::$app->request->post()) && $model->login()) {
    if (Yii::$app->user->isGuest) {
        echo "guest";
    } else {
        echo "User";
    }
    return $this->redirect(['dashboard']);
}
重定向后,如果我运行仪表板功能,它将打印
guest

public function actionDashboard()
{        
    if (Yii::$app->user->isGuest) {
        echo "guest";
    } else {
        echo "User";
    }
}
我的
登录
型号:

public function login()
{
    if ($this->validate()) {
        return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600 * 24 * 30 : 0);
    } else {
        return false;
    }
}        
这是
getUser
函数:

protected function getUser()    
{
    if ($this->_user === null) {
        $this->_user = Customer::findByEmail($this->email);
    }

    return $this->_user;
}

请帮助我检查另一个功能,用户是否已登录?

我已成功修复此问题

只需更改backend/config/main.php或frontend/config/main.php

改变这个

'components' => [
        'user' => [
            'identityClass' => 'common\models\Customer', //or Any models you want
            'enableAutoLogin' => true,
        ],
]

这已经在我的frontend\config\main.php'user'=>['identityClass'=>'frontend\modules\customer\models\customer','enableAutoLogin'=>true,'loginUrl'=>['login'],],请给出任何其他答案?您可以使用Yii调试器发布数据库日志吗?