xiaopy
新手上路

UID 76770
精华
0
积分 6
帖子 5
金钱 6 喜悦币
威望 0
人脉 0
阅读权限 10
注册 2006-7-20
状态 离线
|
奇怪的session问题~
<?php
session_start();
@$username2 = $_SESSION["username"];
include('global.php');
//////////////////////////////////////////////////////////////////
print <<< EOT
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>用户查询系统</title><link rel="stylesheet" href="guide.css">
<base target="_blank">
</head>
<body leftmargin="0" rightmargin="0" topmargin="0">
<script language="JavaScript" src="header.js"></script>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
EOT;
///////////////////////////////////////////////////////////////
@$username = $_POST['username'];
@$password = $_POST['password'];
@$action = $_GET['action'];
if(isset($username2)) {
$message = "欢迎您登陆用户查询系统!";
echo "<tr>"."<td class=\"title\">".$_SESSION["username"]." ".session_id()." ".$message."</td>"."</tr>";
echo "<tr>"."<td>";
echo "</td></tr>";
}else{
if (!isset($username)) {
$message = "对不起,您还没有登陆!";
echo "<tr>"."<td class=\"title\">".$message."</td>"."</tr>";
echo "<tr>"."<td>";
echo "<p>";
include_once("login.html");
echo "</td></tr>";
} else {
$result = $db->query("SELECT count(*) FROM subscriber where username = '$username' and password = '$password'");
$row = mysql_fetch_row($result);
$count = $row[0];
if($count > 0) {
$_SESSION["username"] = $username;
$message = "欢迎您登陆用户查询系统!";
echo "<tr>"."<td class=\"title\">".$_SESSION["username"]." ".session_id()." ".$message."</td>"."</tr>";
echo "<tr>"."<td>";
echo "</td></tr>";
}
}
}
switch($_GET['action']) {
case 'cz':
if(!isset($username2)) {
;
} else {
$message = "您的充值记录!";
echo "<tr>"."<td class=\"title\">".$username2."</td>"."</tr>";
echo "<tr>"."<td>";
require_once('cz.php');
echo "</td></tr>";
}
break;
////////////////////////////////////////
case 'ye':
require_once('global.php');
if(!isset($username2)) {
;
} else {
$message = "您当前的余额!";
echo "<tr>"."<td class=\"title\">".$message."</td>"."</tr>";
echo "<tr>"."<td>";
$result = $db->query("SELECT money FROM subscriber WHERE username='$username2'");
$row = mysql_fetch_row($result);
print $row[0];
echo "</td></tr>";
}
break;
////////////////////////////////////////
case 'exit':
if(!isset($username2)) {
;
} else {
session_destroy();
unset($username2);
unset($action);
$_SESSION=array();
$message = "对不起,您还没有登陆!";
echo "<tr>"."<td class=\"title\">".$message."</td>"."</tr>";
echo "<tr>"."<td>";
include_once("login.html");
echo "</td></tr>";
}
break;
}
//////////////////////////////////////////////////////////////
print <<< EOT
</td></tr></table>
<script language="JavaScript" src="footer.js"></script>
</body>
</html>
EOT;
?> 这是主页index.php,然后上面有几个链接,比如有index.php?action=cz, index.php?action=ye,成功登系统后,会注册一个session变量$_SESSION["username"],可是奇怪的是,如果点index.php?action=cz,可以得到这个session变量,可接着再点index.php?action=ye,这个session变量就消失了,哪位大侠可以帮帮我,先谢过了~
|
|