From c447e900a707d91b02e1ad9e37c7c861715261c1 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Mon, 29 Feb 2016 21:00:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BCookie=E7=B1=BB=E7=9A=84clear?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Cookie.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/library/think/Cookie.php b/library/think/Cookie.php index 9269cf68..3ababc3b 100644 --- a/library/think/Cookie.php +++ b/library/think/Cookie.php @@ -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; }