为什么在按下注销链接时仍然处于登录状态,以及为什么在按下登录链接时仍然注销


Why still signed in status when press sing out link , and Why still signed out when press sign in link?

为什么在按下注销链接时仍然处于登录状态,为什么在按下登录链接时仍然注销?

  1. 加载index.php

  2. 单击Sign in链接,它将加载到sign_in.php并再次重定向到index.php。但是为什么仍然显示You not sign in Sign in(未登录状态)。我必须再次加载页面(F5)以显示You was Signed in success Sign out(已登录状态)

  3. 单击Sign Out链接,它将加载到sign_out.php并再次重定向到index.php。但是为什么仍然显示You was Signed in success Sign out(已登录状态)。我必须再次加载页面(F5)以显示You not sign in Sign in(未登录状态)。

我该怎么办?以通过不再按CCD_ 12来获得唱入/唱出状态。

index.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<body>
<?PHP
include("connect.php");
include("header_test.php");
if ($_SESSION['Username']== "")
{ 
?>
 You not sign in  <a href="sign_in.php">Sign in</a>
<?PHP
}
else
{
?>
 You was Signed in success  <a href="sign_out.php">Sign out</a>
<?PHP
}
?>
</body>
</html>

header_test.php

<?PHP
session_start();
?>

sign_in.php

<?
session_start();
include("connect.php");
$_SESSION["Username"] = "1";
?>
<script language="JavaScript">window.location = 'index.php';</script>

sign_out.php

<?PHP
include("connect.php");
session_start();
session_destroy();
header("location:index.php");
?>

这是由于浏览器的缓存造成的。在打印任何输出之前,请输入以下代码以刷新文件中的浏览器缓存。

//Log out Back
header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1.
header("Pragma: no-cache"); // HTTP 1.0.
header("Expires: 0"); // Proxies.