$_SESSION['id'] = 1;
The unset($_SESSION);
next time you refresh session_start();
the page,
$_SESSION['id']
The values are = 1
out again!
And unset($_SESSION['id']);
the use can be cleared normally!
Who can tell the details, thank you!
Reply content:
$_SESSION['id'] = 1;
The unset($_SESSION);
next time you refresh session_start();
the page,
$_SESSION['id']
The values are = 1
out again!
And unset($_SESSION['id']);
the use can be cleared normally!
Who can tell the details, thank you!
Because of the fact that "literally" is not always obvious and easy to "actually".
unset($_SESSION['id'])
Changes are the $_SESSION
values of the image;
unset($_SESSION)
Changes are $_SESSION
references that do not change the $_SESSION
image.
Only changes $_SESSION
to the image, just will change the actual Session.
If, however, $_SESSION = [];
you can achieve the purpose of emptying the Session.
It is said that the direct value of the $_SESSION
variable can also be changed to the $_SESSION
image.
So, I guess, the PHP engine $_SESSION
modifies the Session by changing the last-referenced image, and if there is no $_SESSION
change, skip this step.
In the context of the current request, $_SESSION
this variable is actually a reference to the array that stores the session value.
unset($_SESSION)
It simply writes this variable in the context of the current request $_SESSION
, and does not actually move to an array of values that store the session.
The next time a request is made, the variable in the context of the next request will naturally be directed to the reference of the $_SESSION
array that stores the session value.
In fact, Kmxz said very clearly,
Whether it's $_get or $_post,$_cookie or $_session,
They are a variable of PHP itself,
When a request comes in, Zend will parse Query_string,body,http_cookie,phpsessionid,
The values are then loaded into the above variables, where the session is in the file in/tmp and the file name is the Phpsessionid value (which means by default).
Session of the storage file is a certain chance to trigger the deletion, if not deleted,
On the next request, Zend will find the session file according to the value of Phpsessionid, and then read and deserialize (non-PHP unserialize function) after re-loaded into the $_session, so the ID has a value.
And you unset ($_session[' id '), changed the value of the corresponding ID in/tmp (actually deleted), so after re-request, the ID is not.