Session_destroy () cannot take effect immediately
In the HTML link to a PHP page, the PHP page will destroy the session, but when the page opens, the session is still there, only to refresh the PHP page again to destroy the session. The page is two statements $_session = Array (); Session_destroy (); Session_Start () is already open.
Excuse me, what's the situation?
------Solution--------------------
You execute Session_destroy () in the B page; The former session naturally exists, otherwise there is no need to Session_destroy (); The
You only have to re-enter the B page (such as refresh) to find that the session is not
Because for the user, Session_destroy () is simply the instruction to send the SessionID in the logout cookie
------Solution--------------------
a.php
Session_Start ();
$_session[' name '] = "Kobe";
?>
Se2
b.php
Session_Start ();
$_session = Array ();
Session_destroy ();
Var_dump ($_session[' name ');
?>
------Solution--------------------
Reference:
Quote: Reference:
So the page has never ended, of course, the current session will not disappear.
connection_aborted () This sentence can check whether the client is disconnected, but it does need to output the content in the page, so add Ob_flush (); flush ();
The problem is that the page that will cause the session to be destroyed does not work properly, i.e. it must be manually refreshed to destroy the session
So there is no other way to close this loop when the client disconnects. Or there is no other way to normally perform the destruction session of that page.
Is there a problem with ob_flush (); flush (); What do we do?
I do this is to prevent users from long-time not landing is kicked off the job, there are other ways?
Your page has not ended and the session of the current page has not been updated to the file. This is why Session_destroy () cannot take effect immediately.
In Session_destroy (); After adding Session_write_close (); can solve this problem.