我正在设置一个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()
功能工作正常。
有任何想法吗?有一个更好的方法吗?