From c5bde960863664f316afe90562d2b82d7799f6b4 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 14 Jun 2016 12:34:08 +0800 Subject: [PATCH] =?UTF-8?q?Cookie=E7=B1=BB=E5=A2=9E=E5=8A=A0has=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Cookie.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/library/think/Cookie.php b/library/think/Cookie.php index d21f3226..30ff81d4 100644 --- a/library/think/Cookie.php +++ b/library/think/Cookie.php @@ -95,6 +95,19 @@ class Cookie $_COOKIE[$name] = $value; } + /** + * 判断Cookie数据 + * @param string $name cookie名称 + * @param string|null $prefix cookie前缀 + * @return bool + */ + public static function has($name, $prefix = null) + { + $prefix = !is_null($prefix) ? $prefix : self::$config['prefix']; + $name = $prefix . $name; + return isset($_COOKIE[$name]) ? $value: null; + } + /** * Cookie获取 * @param string $name cookie名称