Rezvania
Rezvania

Reputation: 57

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. even I checked it by 'isActive' and got a response: 'false' but it's still readable and writable yet.

$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

Upvotes: 1

Views: 54

Answers (1)

ScaisEdge
ScaisEdge

Reputation: 133410

$_SESSION is a PHP global var 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

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

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.

Upvotes: 2

Related Questions