mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
改进Cookie类的clear方法
This commit is contained in:
@@ -76,7 +76,6 @@ class Cookie
|
||||
} elseif (is_string($option)) {
|
||||
parse_str($option, $option);
|
||||
}
|
||||
|
||||
$config = array_merge(self::$config, array_change_key_case($option));
|
||||
} else {
|
||||
$config = self::$config;
|
||||
@@ -88,7 +87,7 @@ class Cookie
|
||||
$value = 'think:' . json_encode($value);
|
||||
}
|
||||
$expire = !empty($config['expire']) ? time() + intval($config['expire']) : 0;
|
||||
if (self::$config['setcookie']) {
|
||||
if ($config['setcookie']) {
|
||||
setcookie($name, $value, $expire, $config['path'], $config['domain'], $config['secure'], $config['httponly']);
|
||||
}
|
||||
$_COOKIE[$name] = $value;
|
||||
@@ -128,7 +127,7 @@ class Cookie
|
||||
$config = self::$config;
|
||||
$prefix = !is_null($prefix) ? $prefix : $config['prefix'];
|
||||
$name = $prefix . $name;
|
||||
if (self::$config['setcookie']) {
|
||||
if ($config['setcookie']) {
|
||||
setcookie($name, '', time() - 3600, $config['path'], $config['domain'], $config['secure'], $config['httponly']);
|
||||
}
|
||||
// 删除指定cookie
|
||||
@@ -154,14 +153,12 @@ class Cookie
|
||||
// 如果前缀为空字符串将不作处理直接返回
|
||||
foreach ($_COOKIE as $key => $val) {
|
||||
if (0 === strpos($key, $prefix)) {
|
||||
if (self::$config['setcookie']) {
|
||||
if ($config['setcookie']) {
|
||||
setcookie($key, '', time() - 3600, $config['path'], $config['domain'], $config['secure'], $config['httponly']);
|
||||
}
|
||||
unset($_COOKIE[$key]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
unset($_COOKIE);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user