session_destroy() cannot take effect immediately, how to solve it

session_destroy() cannot take effect immediatelyWhen linking to a PHP page in HTML, the PHP page will destroy the session, but when the page is opened, the session still exists. Only by refreshing the PHP page again can the session be destroyed. There are only two statements on this page: $_SESSION = array(); session_destroy(); session_start() has been enabled. What is the situation ——Solution—————– —When you execute session_destroy(); in page B, the previous session naturally exists, otherwise there is no need to use session_destroy();You are only re-entering page B (such as refreshing ) will find that the session is goneBecause to the user, session_destroy() only sends the instruction to log out the sessionid in COOKIE——Solution- ——————a.php <?php session_start();$_SESSION[‘name’] = “kobe”;?>se2 >b.php <?phpsession_start();$_SESSION = array();session_destroy( );var_dump($_SESSION[‘name’]);?> ——Solution Scheme——————– Quote: Quote: Quote: Then the page will never end, and of course the current session will not disappear. The connection_aborted() sentence can check whether the client is disconnected, but its execution requires outputting content on the page, so ob_flush();flush();Problem These two sentences will cause the page that destroys the session to fail to execute normally, that is, it must be refreshed manually to destroy the session So, is there any other way to close this…

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: 34331943@QQ.com

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索