24 private static $_reserved = array(
'XOLOGGERVIEW',
'xoops_user');
30 public static function del($key)
36 public static function delete($key)
39 $key = self::_scrubKey($key);
42 if (self::exists($key))
48 list ($k, $v) = each($key);
51 $key = $k .
'[' . $v .
']';
54 setcookie($key,
false, time() - 3600);
57 unset($_COOKIE[$k][$v]);
61 else if (is_array($_COOKIE[$key]))
63 foreach ($_COOKIE[$key] as $k => $v)
66 $cookie = $key .
'[' . $k .
']';
69 setcookie($cookie,
false, time() - 3600);
72 unset($_COOKIE[$key][$k]);
80 setcookie($key,
false, time() - 3600);
83 unset($_COOKIE[$key]);
92 $key = self::_scrubKey($key);
98 list ($k, $v) = each($key);
101 if (isset($_COOKIE[$k][$v]))
return true;
105 else if (isset($_COOKIE[$key]))
return true;
112 public static function get($key)
115 $key = self::_scrubKey($key);
121 list ($k, $v) = each($key);
124 if (isset($_COOKIE[$k][$v]))
return $_COOKIE[$k][$v];
128 else if (isset($_COOKIE[$key]))
return $_COOKIE[$key];
141 public static function set(
151 if (!in_array($key, self::$_reserved))
154 $key = self::_scrubKey($key,
true);
157 setcookie($key, $value, $expire,
$path, $domain, $secure, $httponly);
161 else Error::warning(
'Could not set key -- it is reserved.', __CLASS__);
165 private static function _scrubKey($key, $toString =
false)
174 list ($k, $v) = each($key);
177 $key = $k .
'[' . $v .
']';
182 else if (!is_array($key))
185 if (preg_match(
'/([\w\d]+)\[([\w\d]+)\]$/i', $key, $matches))
188 $key = array($matches[1] => $matches[2]);