我已經完成了一個只能在登錄後才能訪問的頁面。現在我已經完成了一個註銷按鈕,該按鈕可以正常工作,但是在註銷錯誤消息後我得到了該按鈕。兩秒後的重定向工作,會議結束,但我仍然得到以下錯誤:結束會話後出錯
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/u200098000/public_html/logout.php:2) in /home/u200098000/public_html/logout.php on line 3
這是我的代碼:
<?php
session_start();
session_destroy();
echo "<h1>You succesfully logged out</h1>";
echo '<p> If you are not redirected automatically please click <a href="index.html">here</p>';
echo '<script>';
echo 'redirectTime = "2000";';
echo 'redirectURL = "/index.html";';
echo 'setTimeout("window.location = redirectURL",redirectTime);';
echo '</script>';
?>
非常感謝任何幫助。
在代碼的開始處刪除**空白**,也包括在任何文件的開頭。 – Leonardo
http://stackoverflow.com/questions/8812754/cannot-send-session-cache-limiter-headers-already-sent接受的答案是關於在開始會話之前不向瀏覽器發送任何東西。 (如迴應一些東西) –