From e36987fc5d378a24af1d248fb8ba76f287b56bdf Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 13 Dec 2016 14:48:01 +0800 Subject: [PATCH] =?UTF-8?q?Cookie=E7=B1=BB=E5=A2=9E=E5=8A=A0forever?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E7=94=A8=E4=BA=8E=E6=B0=B8=E4=B9=85=E7=BC=93?= =?UTF-8?q?=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Cookie.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/library/think/Cookie.php b/library/think/Cookie.php index 648b2c60..12b5cc31 100644 --- a/library/think/Cookie.php +++ b/library/think/Cookie.php @@ -99,6 +99,22 @@ class Cookie $_COOKIE[$name] = $value; } + /** + * 永久保存Cookie数据 + * @param string $name cookie名称 + * @param mixed $value cookie值 + * @param mixed $option 可选参数 可能会是 null|integer|string + * @return void + */ + public static function forever($name, $value = '', $option = null) + { + if (is_null($option) || is_numeric($option)) { + $option = []; + } + $option['expire'] = 315360000; + self::set($name, $value, $option); + } + /** * 判断Cookie数据 * @param string $name cookie名称