我看到了很多關於這個問題,即時通訊仍然有問題...有人可以給我一個幫助嗎?在php中銷燬會話
登錄頁面:
<?PHP
header("Content-Type: text/html; charset=utf-8");
$login = "root";
$senha = "test";
session_start();
session_set_cookie_params(0);
if ($_POST['login'] && $_POST['senha']) {
if ($login == $_POST['login'] && $senha == $_POST['senha']) {
$_SESSION['login'] = $login;
$_SESSION['senha'] = $senha;
Header("Location: index.php");
} else {
unset ($_SESSION['login']);
unset ($_SESSION['senha']);
header("Location: login.php");
}
}
?>
註銷頁面:
<?php
session_start();
$_SESSION = array();
unset($_SESSION['login']);
unset($_SESSION['senha']);
setcookie(session_name(), '', time() - 3600, '/');
session_destroy();
Header("Location: login.php");
exit();
?>
即時得到這個錯誤:
PHP Warning: session_destroy(): Session object destruction failed in \\N\Users\cPanel\gil\public_html\gilberto\logout.php on line 11
請參考http://stackoverflow.com/questions/3512507/proper-way-to-logout-from-a-session-in-php。 –