我想从不同的表中使用不同的凭据登录前端和后端,所以我现在有不同的表单、模型、规则等。。。
我试着像Yii那样设置stateKeyPrefix
,但它不起作用。
有人知道我想怎么登录吗?
下面的方法返回true,因为我已经在前端登录了n;
public function actionLogin() {
if (!'Yii::$app->user->isGuest) {
return $this->goHome();
}
$model = new LoginAdminForm();
if ($model->load(Yii::$app->request->post()) && $model->login()) {
return $this->goBack();
} else {
return $this->render('login', [
'model' => $model,
]);
}
}
您应该在用户配置中定义stateKeyPrefix:
'user'=>array(
'stateKeyPrefix'=>'yourDifferentPrefixForEveryDomain',
...
),
会话组件中的不同会话名称:
'session' => array (
'sessionName' => 'differentSessionNameForEveryDomain',
...
),