我設置一個cookie如下:PHP刪除Cookie問題
if($persist=='persist'){ // if remember me then set long cookie expiration
setcookie("aukCookie", "$user", time()+9900000, "/", "myurl.com");
setcookie("aukCookie2", "$username", time()+9900000, "/", "myurl.com");
setcookie("AUKpersist", "$user", 0, "/", "myurl.com");
} else {
setcookie("aukCookie", "$user", time()+86400, "/", "myurl.com");
setcookie("aukCookie2", "$username", time()+9900000, "/", "myurl.com");
}
然後刪除我去同一個文件,url變量?logoff=true
然後我嘗試以下方法:
if ($_GET[logoff]=='true'){
setcookie ("aukCookie", "", time()-3600, "/", "myurl.com");
setcookie ("AUKpersist", "", time()-3600, "/", "myurl.com");
// use below to send user somewhere when logged out successfully
header("Location: /userAdmin/userlogin.html?loggedOut");
}
但是這個cookie根本就沒有被刪除。 header()
函數工作正常。
任何想法?有一個更好的方法嗎?
是'header'頁面發送數據之前叫這就是你需要使用'cookie'也許'session' – Jacopofar 2013-03-18 12:12:04
,感謝 – mkjasinski 2013-03-18 12:12:17