解决YII注销问题?

解决YII注销问题?,yii,Yii,我在登录时选中“记住我”复选框,并在代码中签入这一点: if($this->_identity->errorCode===UserIdentity::ERROR_NONE) { $duration= 3600*24*30; // 30 days Yii::app()->user->login($this->_identity,$duration); return true; } 所以我在设定这个。但是,如果我离开浏览器回来,我就会注销。关于我能看到的可

我在登录时选中“记住我”复选框,并在代码中签入这一点:

if($this->_identity->errorCode===UserIdentity::ERROR_NONE) {
  $duration= 3600*24*30; // 30 days
  Yii::app()->user->login($this->_identity,$duration);
  return true;
}

所以我在设定这个。但是,如果我离开浏览器回来,我就会注销。关于我能看到的可能导致这种情况的原因,有什么想法吗?

您需要在config/main.php文件中设置allowAutoLogin以允许基于cookie的登录

   'components' => array(
        'user'=>array(
            // enable cookie-based authentication
            'allowAutoLogin'=>true,
            ...
        ),
    ...

您需要在config/main.php文件中设置allowAutoLogin以允许基于cookie的登录

   'components' => array(
        'user'=>array(
            // enable cookie-based authentication
            'allowAutoLogin'=>true,
            ...
        ),
    ...

你在用Chrome吗?打开开发人员工具并转到“资源”选项卡。在左侧菜单中,您能看到正在为您的站点设置cookie(在cookies下)吗?我看到正在设置大量cookies?我必须找一个特别的吗?你用的是Chrome吗?打开开发人员工具并转到“资源”选项卡。在左侧菜单中,您能看到正在为您的站点设置cookie(在cookies下)吗?我看到正在设置大量cookies?我必须找一个特别的吗?