public function fetchCookieToSend($host, $path)
    {
        $now = time();
        $host = strtolower($host);
        $cookies = [];
        $domains = ['-', $host];
        while (strlen($host) > 1 && ($pos = strpos($host, '.', 1)) !== false) {
            $host = substr($host, $pos + 1);
            $domains[] = $host;
        }
        foreach ($domains as $domain) {
            if (!isset($this->_cookies[$domain])) {
                continue;
            }
            foreach ($this->_cookies[$domain] as $_path => $list) {
                if (!strncmp($_path, $path, strlen($_path))
                    && (substr($_path, -1, 1) === '/' || substr($path, strlen($_path), 1) === '/')
                ) {
                    foreach ($list as $k => $v) {
                        if (!isset($cookies[$k]) && ($v['expires'] === null || $v['expires'] > $now)) {
                            $cookies[$k] = $k . '=' . $v['value'];
                        }
                    }
                }
            }
        }
        return $cookies;
    }