public function isThere(string $uri): bool
    {
        if (empty($uri)) {
            return true;
        }
        $uri = parse_url($uri);

        //检查是否在路径中
        if ($this->path !== '/' && strpos($uri['path'], rtrim($this->path, '/')) === false) {
            return false;
        }

        if ($this->hostonly) {
            return $this->domain === $uri['host'];
        } else {
            $rest = str_replace($this->domain, '', $uri['host'], $is_there);
            //uri的host中是否包含了该cookie的domain
            if ($is_there) {
                if (substr_count($rest, '.') > 1) {
                    //通配符匹配,最多向下一级(参考chrome)
                    return false;
                } else {
                    return true;
                }
            } else {
                return false;
            }
        }
    }
public function isThere(string $uri): bool
    {
        if (empty($uri)) {
            return true;
        }
        $uri = parse_url($uri);

        //检查是否在路径中
        if ($this->path !== '/' && strpos($uri['path'], rtrim($this->path, '/')) === false) {
            return false;
        }

        if ($this->hostonly) {
            return $this->domain === $uri['host'];
        } else {
            $rest = str_replace($this->domain, '', $uri['host'], $is_there);
            //uri的host中是否包含了该cookie的domain
            if ($is_there) {
                if (substr_count($rest, '.') > 1) {
                    //通配符匹配,最多向下一级(参考chrome)
                    return false;
                } else {
                    return true;
                }
            } else {
                return false;
            }
        }
    }
public function isThere ( string $ uri ) : bool { if ( empty ( $ uri ) ) { return true ; } $ uri = parse_url ( $ uri ) ; //检查是否在路径中 if ( $ this -> path !== '/' && strpos ( $ uri [ 'path' ] , rtrim ( $ this -> path , '/' ) ) === false ) { return false ; } if ( $ this -> hostonly ) { return $ this -> domain === $ uri [ 'host' ] ; } else { $ rest = str_replace ( $ this -> domain , '' , $ uri [ 'host' ] , $ is_there ) ; //uri的host中是否包含了该cookie的domain if ( $ is_there ) { if ( substr_count ( $ rest , '.' ) > 1 ) { //通配符匹配,最多向下一级(参考chrome) return false ; } else { return true ; } } else { return false ; } } }
Check if the cookie belongs to this url

@param string $uri

@return bool
Check if the cookie belongs to this url