私はクッキーを設定するためにこの関数を持っています:
private function setCookie($key, $value){
if(setcookie(
$key,
$this->encrypt($value),
time() + 2592000,
adminpath,
database::getDomain(),
database::getHTTPS(),
true
)){ // set cookie for a month
return true;
}
else{ // cookie could not be created, write to errorlog
$error = array(
"type" => "other",
"argument" => 1,
"class" => __CLASS__,
"function" => __FUNCTION__,
"errorMsg" => "Could not create cookie ".$key." with value ".$value,
"file" => __FILE__,
"line" => __LINE__
);
$this->errorlog->log($error);
return false;
}
}
次に、このコードを使用してCookieの設定を解除します。
private function destroyCookie($key){
if(setcookie(
$key,
" ",
time() - (time() + 2592000),
adminpath,
database::getDomain(),
database::getHTTPS(),
true
)){
return true;
}
else{
$error = array(
"type" => "other",
"argument" => 1,
"class" => __CLASS__,
"function" => __FUNCTION__,
"errorMsg" => "Could not destroy cookie ".$key,
"file" => __FILE__,
"line" => __LINE__
);
$this->errorlog->log($error);
return false;
}
}
おそらく非常に単純なものが欠けていますが、Cookieが削除されない理由がわかりません。両方の関数は同じクラスにあり、関数database :: getDomain()は「www.creetab.com」になり、関数database :: getHTTPS()は「false」になります。adminpathは「/admin/」です。誰かが私がこの問題を解決するのを手伝ってくれませんか?Cookieの設定は正常に機能し、機能しないCookieを削除するだけです。