session问题
1、为什么第一次打开浏览器后总是显示“goood非法用户”,按返回后,在输入密码用户名就可以正常登陆了
。
2、为什么session文件在电脑里每登陆一次就增加一个,这样不是很快就会把硬盘占完了吗?怎么样自动删除
这些文件?(我的存储地址是c:\windows\temp\)
<?session_start()?>
<?
require("../config/config.php");
if($name==""){
$info="请输入姓名";
header("location:../index.php?info=$info");
exit;
}
else if($password==""){
$info="请输入密码";
header("location:../index.php?info=$info");
exit;
}
else{
$sql = "select password from user where name='".$name."'";
$result = mysql_query($sql, $connect);
if($result){
$row=mysql_fetch_array($result);
$temp=$row[0];
mysql_close($connect);
if($temp!=$password){
$info="密码不正确,请重新输入";
header("location:../index.php?info=$info");
exit;
}
else{
$info="登陆成功";
session_register("name");
header("location:../index1.php");//自动切换到index1.php页面,有没有好别的好的办法实
现?
exit;
}
} //结束 if($result) 语句块
}
?>
index1.php文件如下
<?session_start()?>
<?
if (session_is_registered("name"))
{ ?>
………………//代码
<? }
else
{
echo "goood";
echo "非法用户";
}?>