无法设置http_referer
问题描述:
如何在登录后(使用signin.php)在我的logout.php
页面中设置我的http_referer
位置,该页面成功登录重定向到joomla.php,我给出的注销链接(使用href)现在我想点击注销&转到`登录。 PHP &我得到HTTP_REFERER是joomla.php所以汉王我可以设置logout.php无法设置http_referer
-
代码:Signin.php
$referer = $_SERVER['HTTP_REFERER']; echo $referer; if ($referer == 'http://localhost/MinProject/reg.php') { echo "Registration SuccessFully"; } else if($referer=='http://localhost/MinProject/changepassword.php') { echo"Change Password SuccessFully"; }
-
joomla.php
<html> <body> <table width="100%"> <tr> <td width="20%" height="32" align="right" class="unm"> <?php session_start(); if(isset($_SESSION['username'])) { $name =$_SESSION['username']; echo "Welcome ".$name; } ?> </td> <td width="64%" height="32" align="right"> <a href="changepassword.php">ChangePassword</a> </td> <td width="10%" align="right"> <a href="logout.php">logout</style></a> </td> <td width="11%"></td> <td width="5%"></td> <td width="5%"></td> <td width="5%"></td> </tr> </table> </body> </html>
-
logout.php
session_start(); unset($_SESSION['username']); session_destroy(); response.setHeader("Location: http://localhost/MinProject/logout.php"); header("Location: Signin.php"); exit();
答
HTTP_REFERER可以被欺骗,所以你不应该使用。
看着你的代码,我认为你正在努力实现。
$Message = $_SESSION['MESSAGE'];//set the message Registration SuccessFully if registration else set it as Change Password SuccessFully or accordingly
if (isset($Message) and userhasidentity)
{
echo $Message;
}else
{
header('location:logout.php');
}
从不使用$ _ SERVER这样的事情 – 2013-02-04 08:13:53
你不能“设置HTTP_REFERER”,这是环境的一部分[“HTTP_REFERER”]。 – leftclickben