我已经实施了Yii 1.1。一切都是工作文件,但记住我不工作。 我的代码如下。
'user' => array(
// enable cookie-based authentication
'allowAutoLogin' => true,
),
在站点控制器登录操作中。
public function actionLogin() {
$this->layout = "simple";
$model = new LoginForm;
// if it is ajax validation request
if (isset($_POST['ajax']) && $_POST['ajax'] === 'login-form') {
echo CActiveForm::validate($model);
Yii::app()->end();
}
// collect user input data
if (isset($_POST['LoginForm'])) {
$model->attributes = $_POST['LoginForm'];
// validate user input and redirect to the previous page if valid
if ($model->validate() && $model->login())
$this->redirect(Yii::app()->getBaseUrl(true) . "/site/index");
}
// display the login form
$this->render('login', array('model' => $model));
}
public function login()
{
$session=new CHttpSession;
$session->open();
if($this->_identity===null)
{
$this->_identity=new UserIdentity($this->username,$this->password);
$this->_identity->authenticate();
}
if($this->_identity->errorCode===UserIdentity::ERROR_NONE)
{
$duration=$this->rememberMe ? 3600*24*30 : 0; // 30 days
Yii::app()->user->setId($session["uid"]);
Yii::app()->user->login($this->_identity,$duration);
return true;
}
else
return false;
}
我试图检查记住我的字段是否存在所以,如果我选择了那么我记得我的值是真的,也是持续时间设置,也适用于那个,最后它返回我的真实。但是,一旦我退出并检查登录表单,然后没有自动完成用户名和密码?