php中的会话立即将我注销

时间:2014-11-15 11:49:33

标签: php session register-globals

我是php的新手,并且坚持使用为php4编写的旧代码。一切似乎都运行正常,我甚至在这里快速修复了register_globals。问题是,我点击任何链接后立即退出,所以我怀疑这次是一个会话问题。请为我检查一下:

<?
foreach (array_merge($_GET, $_POST) as $key => $val) {
  global $$key;
  $$key = addslashes($val);
}
@session_start(); 
include("../dbinfo.php");
$expireTime = 60;
@session_set_cookie_params($expireTime);

if(isset($bye)) {
    $_SESSION['session_unregister']= 'login';
    $_SESSION['session_unregister']= 'password';
    $_SESSION['time']= time();
    include("logout.php"); 
    exit;
        } 
if(!isset($login)) { 
    include("loginform.php");
exit; }

$_SESSION['login']= 'login';
$_SESSION['password']= 'password';
mysql_connect($DBhost, $DBuser, $DBpass) or DIE("Unable to connect to database");
@mysql_select_db($DBName) or die("Unable to select database");

$myquery="select loginname,password from $table where loginname='$login' and   password='$password'";
$result = mysql_query($myquery);
$num_result = mysql_num_rows($result);

if(!$num_result) { 
    $_SESSION['session_unregister']= 'login';
    $_SESSION['session_unregister']= 'password';
    ?>
        <html>
            <head>
            <title> Access Denied </title>
            <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>

<body bgcolor="#CCCCCC">
<h1> Access Denied </h1>
            <p>Your user ID or password is incorrect, or you are not a
        registered user on this site. To try logging in again, click
            <a href="<?=$PHP_SELF?>">here</a>.</p>
            </body>
        </html>

<? exit;
}
?>  

&LT;

0 个答案:

没有答案