内核更新
This commit is contained in:
@@ -30,6 +30,8 @@ class Cookie
|
||||
'setcookie' => true,
|
||||
];
|
||||
|
||||
protected static $init;
|
||||
|
||||
/**
|
||||
* Cookie初始化
|
||||
* @param array $config
|
||||
@@ -44,6 +46,7 @@ class Cookie
|
||||
if (!empty(self::$config['httponly'])) {
|
||||
ini_set('session.cookie_httponly', 1);
|
||||
}
|
||||
self::$init = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,6 +74,7 @@ class Cookie
|
||||
*/
|
||||
public static function set($name, $value = '', $option = null)
|
||||
{
|
||||
!isset(self::$init) && self::init();
|
||||
// 参数设置(会覆盖黙认设置)
|
||||
if (!is_null($option)) {
|
||||
if (is_numeric($option)) {
|
||||
@@ -103,6 +107,7 @@ class Cookie
|
||||
*/
|
||||
public static function has($name, $prefix = null)
|
||||
{
|
||||
!isset(self::$init) && self::init();
|
||||
$prefix = !is_null($prefix) ? $prefix : self::$config['prefix'];
|
||||
$name = $prefix . $name;
|
||||
return isset($_COOKIE[$name]);
|
||||
@@ -116,6 +121,7 @@ class Cookie
|
||||
*/
|
||||
public static function get($name, $prefix = null)
|
||||
{
|
||||
!isset(self::$init) && self::init();
|
||||
$prefix = !is_null($prefix) ? $prefix : self::$config['prefix'];
|
||||
$name = $prefix . $name;
|
||||
if (isset($_COOKIE[$name])) {
|
||||
@@ -139,6 +145,7 @@ class Cookie
|
||||
*/
|
||||
public static function delete($name, $prefix = null)
|
||||
{
|
||||
!isset(self::$init) && self::init();
|
||||
$config = self::$config;
|
||||
$prefix = !is_null($prefix) ? $prefix : $config['prefix'];
|
||||
$name = $prefix . $name;
|
||||
@@ -160,7 +167,7 @@ class Cookie
|
||||
if (empty($_COOKIE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
!isset(self::$init) && self::init();
|
||||
// 要删除的cookie前缀,不指定则删除config设置的指定前缀
|
||||
$config = self::$config;
|
||||
$prefix = !is_null($prefix) ? $prefix : $config['prefix'];
|
||||
|
||||
Reference in New Issue
Block a user