我正在使用以下代碼來使會話無效。我在很多頁面都鏈接到logout.php
。如果該註銷鏈接被點擊,則調用logout.php
頁面。以下是logout.php
中的代碼。PHP會話問題
unset($_SESSION['admin']);
session_destroy();
header('Location: index.php');
一旦會話失效我想開index.php
頁面。 但我歌廳以下錯誤:
Warning: session_destroy() [function.session-destroy]: Trying to destroy uninitialized session in C:\xampp\htdocs\Selection\logout.php on line 3
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\Selection\logout.php:3) in C:\xampp\htdocs\Selection\logout.php on line 4
有什麼不對?
爲什麼一直低估,他是對的。 – 2009-08-30 13:32:36
謝謝......無論如何,必須在腳本開始時調用session_start()。 – mck89 2009-08-30 13:34:08