0

私はセッションスクリプトを持っていますが、Cookieと一緒にそれを破棄する方法がわかりません。エラーが発生しました:「website」のWebページでリダイレクトが多すぎます。このサイトの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();
}  

?>

私はこのスクリプトを見つけましたが、それはクッキーを破壊していません。

<?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 に答える