我有会话脚本,但我不知道如何将其与cookie一起销毁。我有一个错误:“网站”的网页导致了太多的重定向。清除此站点的cookie或允许第三方cookie可以解决问题。如果没有,它可能是服务器配置问题,而不是您的计算机的问题。我不知道正确的脚本需要。
<?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();
}
&GT;
我找到了这个脚本,但它没有破坏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();
?>
答案 0 :(得分:0)
标题应该是这样的
header("location: ADMINLOGIN.php");
^ //space should present otherwise it is not redirecting properly.