Ejemplo n.º 1
0
 /**
  * 移除cookie
  * @param string $key
  * @param string $url
  * @return void
  */
 public static function remove($key, $url = null)
 {
     if (!isset($_COOKIE[$key])) {
         return;
     }
     $path = '/';
     if (!empty($url)) {
         $parsed = parse_url($url);
         $path = empty($parsed['path']) ? '/' : Base_Common::url(null, $parsed['path']);
     }
     if (is_array($_COOKIE[$key])) {
         foreach ($_COOKIE[$key] as $name => $val) {
             setcookie("{$key}[{$name}]", '', time() - 2592000, $path);
         }
     } else {
         setcookie($key, '', time() - 2592000, $path);
     }
 }