[英]Cookies are not deleted in Google Chrome if use yii2
I use framework Yii2.我使用框架 Yii2。 When i make:
当我做:
Yii::$app->user->login($this->getUser(), 60);//cookies for 60 seconds
Browser Google Chrome does not remove cookies after the expiration of 60 seconds.浏览器 Google Chrome 在 60 秒到期后不会删除 cookie。
If I do not use a framework Yii2:如果我不使用 Yii2 框架:
setcookie("test", time() + (60), "/");
it all works.一切正常。
Why, if you use Yii2, that does not work delete cookies in browser GoogleChrom?为什么,如果您使用 Yii2,在浏览器 GoogleChrom 中删除 cookie 不起作用?
The Yii::$app->user->login($user, $duration);
Yii::$app->user->login($user, $duration);
only sets the time the _identity-cookie is alive if the browser is closed.如果浏览器关闭,则仅设置 _identity-cookie 的活动时间。
To log someone out after a set time of inactivity you have to set duration to null
and add 'authTimeout' => 60
in the user component.要在设置的不活动时间后注销某人,您必须将持续时间设置为
null
并在用户组件中添加'authTimeout' => 60
。
common\\models\\LoginForm.php常见\\模型\\LoginForm.php
...
return Yii::$app->user->login($this->getUser(), null);
...
frontend\\config\\main.php前端\\配置\\main.php
...
'components' => [
'user' => [
'identityClass' => 'common\models\User',
'enableAutoLogin' => true,
'authTimeout' => 60,
],
...
Yii2 comes with great documentation, I advice having a look: http://www.yiiframework.com/doc-2.0/yii-web-user.html Yii2 有很好的文档,我建议看看: http ://www.yiiframework.com/doc-2.0/yii-web-user.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.