PHP - 关闭浏览器后会话销毁 [英] PHP - Session destroy after closing browser
问题描述
虽然这个问题有多个重复,我找不到适当的解决方案。
需要一些帮助。
Though this question has multiple duplicates i could not find proper solution for me. Need Some help.
我使用了 ini_set('session.cookie_lifetime',0);
在我的配置文件。
I have used ini_set('session.cookie_lifetime', 0);
in my configuration file.
但它不帮助我在浏览器关闭会话。
But it is not helping me to destroy session on browser close.
应用程序当前流程:
1)如果用户有效, code> session_regenerate_id(true);
1) In authentication page if user is valid, generate new session identifier using session_regenerate_id(true);
2)控制转到welcome.php,其中使用 session_start();
2) Control goes to welcome.php where i start new session using session_start();
3)退出页面代码是
$_SESSION = array();
if (ini_get("session.use_cookies")) {
$params = session_get_cookie_params();
setcookie(session_name(), '', time() - 42000,
$params["path"], $params["domain"],
$params["secure"], $params["httponly"]
);
}
// Finally, destroy the session.
session_destroy();
推荐答案
最好的方法是关闭会话:if在特定时间间隔之后没有对该会话的响应。然后关闭。请参阅这篇文章,我希望它会解决这个问题。 如何更改PHP中的会话超时?
The best way is to close the session is: if there is no response for that session after particular interval of time. then close. Please see this post and I hope it will resolve the issue. "How to change the session timeout in PHP?"
这篇关于PHP - 关闭浏览器后会话销毁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!