简体   繁体   English

似乎会话并未在yii2中被完全破坏

[英]It seems that session was not destroyed precisely in yii2

I tried to destroy my 'session' , but it seems session is accessible Properly after that destruction. 我试图销毁我的'session' ,但在销毁之后似乎可以正确访问会话。 even I checked it by 'isActive' and got a response: 'false' but it's still readable and writable yet. 即使我通过'isActive'对其进行了检查,并得到了一个响应: 'false'但它仍然可读可写。

$session=Yii::$app->session;
$session->close();
$session->destroy();
$session->isActive ? $m='ya' : $m='no';
echo $m; // responded 'false'
$_SESSION['test']=1; //session is accessible properly yet
echo $_SESSION['test']; // session response 1

$_SESSION is a PHP global var PHP:SESSION-DOCS $_SESSION是一个PHP全局变量PHP:SESSION-DOCS

An associative array containing session variables available to the current script. 包含当前脚本可用的会话变量的关联数组。 See the Session functions documentation for more information on how this is used. 有关如何使用此功能的更多信息,请参见会话功能文档。

This means that $_SESSION is always active .. destroy() should "destroy" the actual content of the $_SESSION 这意味着$_SESSION始终处于活动状态.. destroy()应该“销毁” $_SESSION的实际内容

http://www.yiiframework.com/doc-2.0/yii-web-session.html http://www.yiiframework.com/doc-2.0/yii-web-session.html

http://www.yiiframework.com/doc-2.0/yii-web-session.html#destroy()-detail http://www.yiiframework.com/doc-2.0/yii-web-session.html#destroy()-detail

destroy()

In detail Frees all session variables and destroys all data registered to a session. 详细释放所有会话变量,并销毁注册到会话的所有数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM