我只是想寫一些代碼來檢查會話是否存在。如果答案爲否,則將頁面重定向到登錄頁面。此外,我想寫這個代碼爲多個網站。所以無論域名對我來說都永遠不會成爲事實。 這裏我寫一些代碼:header()php not working
//$_SESSION['license'] -> this will be created after anyone log in
//and will be set its value to 15497852.
if(isset($_SESSION['license']) && $_SESSION['license'] == '15497852'){
// DO SOMETHING
} else {
// here i want to create link like: http://stackoverflow.com/?df=login
header('Location: '.$_SERVER['PHP_SELF'].'?df=login');
die();
}
但是這個代碼不工作在那裏我沒有看到任何錯誤。
有沒有一個在我的本地電腦使用wamp服務器的代碼... 有沒有發生這種情況時在頁面中寫入錯誤? – NoLifeKing 2012-03-24 07:56:08
沒有錯誤出現... – 2012-03-24 07:58:29
您是否在header()調用之前在輸出上放置了任何內容? – xea 2012-03-24 07:59:38