我试图让一个人登录系统,直到浏览器中的页面打开。我的代码是:
($GLOBALS["___mysqli_ston"] = mysqli_connect($hostname, $username, $password)) or DIE('NOT Connected!');
((bool)mysqli_query($GLOBALS["___mysqli_ston"], "USE $dbname")) or DIE('Database name is not available!');
$login = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT * FROM student WHERE (name = '" .addslashes($_POST['username']) . "') and ( password = '" .($_POST['password']) . "')");
$row=mysqli_fetch_array($login);
$a = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT * FROM admin WHERE (username = '" .addslashes($_POST['username']) . "') and (password = '" .sha1($_POST['password']) . "')");
$r=mysqli_fetch_array($a);
if($row){
$_SESSION['user'] = $row['name'];
$_SESSION['lname'] = $row['lname'];
$_SESSION['pass'] = $row['pass']
setcookie("cookname", $_SESSION['name'], time()+60*60*24*100, "/");
setcookie("cookpass", $_SESSION['pass'], time()+60*60*24*100, "/");
header ("location: ../../gui-student.php");
}
elseif($r){
$_SESSION['admin'] = $row['id'];
header ("location: gui-admin.php");
}
else {
header ("location: ../../index.html?err");
}
if($row==1)
{
session_start();
$_SESSION['username']=$userName;
header("location: ../../gui-employee.php");
exit();
}
我试过了,但它没有用。我是cookies新手,我不知道如何检查gui-student.php页面上的cookie。
提前感谢您
RGDS
Bhawna
答案 0 :(得分:0)
要检查Cookie,请使用..
在您的情况下, $_COOKIE['cookie_name'];
将是$_COOKIE['cookname'];
或$_COOKIE['cookpass'];
这将给出您在Cookie中设置的值,即$_SESSION['name']
或$_SESSION['pass']
。