我正在创建一个简单的Logout脚本,但由于某些原因,我的cookie("is_logged_in"
)无法删除,尽管我付出了很多努力。
我尝试了以下所有(+更多):
setcookie("is_logged_in");
setcookie("is_logged_in","");
setcookie("is_logged_in","",time()-3600);
setcookie("is_logged_in","",time()-3600,"\");
setcookie("is_logged_in",FALSE); # or NULL, 0, etc.
unset($_COOKIE["is_logged_in"]);
这是我的PHP代码(是的,有一个session_start()
,但它不包含在此摘录中。)
<?php
require_once $_SERVER["DOCUMENT_ROOT"]."/taxi/support/required_classes.php";
ob_start();
class Logout {
final public function __construct(){
$_SESSION = array();
if(isset($_COOKIE["is_logged_in"])) {
setcookie("is_logged_in","",time()-3600,"/");
} // end if
session_destroy();
header("location: ../pages/index.php");
} // end __construct
} // end class Logout
$_logout = new Logout();
ob_flush();
?>