Cookie类增加forever方法用于永久缓存

This commit is contained in:
thinkphp
2016-12-13 14:48:01 +08:00
parent 965e14eb76
commit e36987fc5d

View File

@@ -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名称