我不熟悉Yii,这是登录函数(path/basic/controllers/siteController.php),一旦用户登录,它将呈现登录模板。
用户登录后,
如何获取会话ID并存储到DB?
public function actionLogin()
{
if (!Yii::$app->user->isGuest) {
return $this->goHome();
}
$model = new LoginForm();
if ($model->load(Yii::$app->request->post()) && $model->login()) {
return $this->goBack();
}
return $this->render('login', [
'model' => $model,
]);
}
以及模型代码(path/models/LoginForm.php)
public function login()
{
if ($this->validate()) {
return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600*24*30 : 0);
}
return false;
}