我正在尝试创建一个 PHP 注销脚本,但是,一旦我实现它,页面就会在登录后被重定向到该页面。这是代码:
连接.php
<?php
session_start();
$link = mysql_connect("localhost", "database_name", "database_pass") or die(mysql_error());
mysql_select_db("database_name") or die(mysql_error());
if(isset($_COOKIE['username']))
$_SESSION['username'] = $_COOKIE['username'];
?>
注销.php
<?php
include("connect.php");
session_start();
session_destroy();
$username = $_SESSION['username'];
setcookie($username, time()-3600);
header("Location: index.php");
die;
?> //immediately after here, instead of going to index.php(the login page), it goes straight to the page that would appear after if the user had logged in(control_panel.php).
有任何想法吗?谢谢!