0

我有一个会话脚本,但我不知道如何将其与 cookie 一起销毁。我有一个错误:“网站”上的网页导致了太多重定向。清除此站点的 cookie 或允许第三方 cookie 可能会解决问题。如果不是,则可能是服务器配置问题,而不是您的计算机问题。我不知道正确的destoy脚本需要。

<?php 
session_start();
if(!isset($_SESSION['manager'])){
header("location:ADMINLOGIN.php");
exit();
}
//Be sure to check that this manager SESSION value is in fact in the database
$managerID = preg_replace('#[^0-9]#i', '', $_SESSION["id"]); // filter everything but numbers and letters
$manager = preg_replace('#[^A-Za-z0-9]#i', '', $_SESSION["manager"]); // filter everything but numbers and letters
$password = preg_replace('#[^A-Za-z0-9]#i', '', $_SESSION["password"]); //filter everything but numbers and letters 
//Run mySQL qquery to be sure that this person is an admin and that thier password session var equals the database information
//Connect to the MySQL database
include"CONFIG.php";
$sql=mysql_query("SELECT * FROM administrator WHERE ID='$managerID' AND USERNAME='$manager' AND PASSWORD='$password' LIMIT 1");//query the person
//MAKE SURE PERSON EXISTS IN DATABASE
$existCount = mysql_num_rows($sql);//count the row nums
if($existCount==0){//evvaluate the count
echo "Your login session data is not on record in the database";
exit();
}  

?>

我找到了这个脚本,但它并没有破坏 cookie。

<?php
// Finds all server sessions
session_start();
// Stores in Array
$_SESSION = array();
// Swipe via memory
if (ini_get("session.use_cookies")) {
// Prepare and swipe cookies
$params = session_get_cookie_params();
// clear cookies and sessions
setcookie(session_name(), '', time() - 42000,
    $params["path"], $params["domain"],
    $params["secure"], $params["httponly"]
);
}
// Just in case.. swipe these values too
ini_set('session.gc_max_lifetime', 0);
ini_set('session.gc_probability', 1);
ini_set('session.gc_divisor', 1);
// Completely destory our server sessions..
session_destroy();
?>
4

1 回答 1

0

标题应该是这样的

header("location: ADMINLOGIN.php");
                 ^ //space should present otherwise  it is not redirecting properly.
于 2012-10-03T04:11:34.863 回答