我在用户注销帐户时遇到了破坏会话的问题。当我浏览任何限制用户不能在登录前访问的页面登出后我可以访问但是如果我在注销后关闭我的浏览器然后尝试访问该页面我不能。请解决我的问题,以便用户在注销后无法访问页面,即使他/她没有关闭浏览器。这是我的退出和销毁会话的代码。
<?php
// Initialize the session.
// If you are using session_name("something"), don't forget it now!
if(isset($_POST['logout'])){
session_start();
// Unset all of the session variables.
$_SESSION = array();
$_SESSION["Alogin"] = "";
// If it's desired to kill the session, also delete the session
cookie.
// Note: This will destroy the session, and not just the session data!
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();
}
?>
答案 0 :(得分:0)
session_start ();
放在if语句和print_r ($_POST);
$_POST['logout']
核对
醇>
答案 1 :(得分:0)
会话var firstDate = new Date(2006,05,09);
var secondDate = new Date(1990,01,01);
function (firstDate, secondDate){
var oneDay = 24*60*60*1000; // hours*minutes*seconds*milliseconds
var diffDays = Math.round(Math.abs((firstDate.getTime() - secondDate.getTime())/(oneDay)));
return diffDays;
}
必须位于顶部
session_start()