0 php
我在这里有这个类,我想要做的是,如果检查某些东西等于false,那么用户将被重定向到根域路径.但它不起作用.这是班级
class security {
function checkAuth() {
if(isset($_COOKIE['AUTHID'])) {
$cookie = $this->secure($_COOKIE['AUTHID']);
$query = mysql_query("select username,password,active from tbl_users where password = '$cookie'") or die(mysql_error());
while($row = mysql_fetch_assoc($query)) {
//check if cookie is set
if(!isset($_COOKIE['AUTHID'])) {
header("Location: ".realpath($_SERVER['HTTP_HOST']));
}
//check if user is active
if($cookie == $row['password']) {
if($row['active'] == '0') {
setcookie("AUTHID","",time() - 100000);
header("Location: ".realpath($_SERVER['HTTP_HOST']));
}
else { //user is active
}
}
//check if hash in cookie matches hash in db
if($cookie != $row['password']) {
setcookie("AUTHID","",time() - 100000);
header("Location: ".realpath($_SERVER['HTTP_HOST']));
}
}
}
}
}
?>
Run Code Online (Sandbox Code Playgroud)
尝试
$_SERVER['SCRIPT_URI'];
Run Code Online (Sandbox Code Playgroud)
要么
"http://" . $_SERVER['HTTP_HOST'];
Run Code Online (Sandbox Code Playgroud)
是的,退出(); 发送该标题后
不要忘记为重定向发送适当的30x 标头响应代码
| 归档时间: |
|
| 查看次数: |
16030 次 |
| 最近记录: |