public function replace($name, $value)
    {
        $cookieList = [];
        foreach ($this->header->ls() as $hdr) {
            if (0 === \stripos($hdr, 'Set-Cookie: ')) {
                // found "Set-Cookie"
                if (0 !== \stripos($hdr, \sprintf('Set-Cookie: %s=', $name))) {
                    // not the one we want to replace, add to backup list
                    $cookieList[] = $hdr;
                }
            }
        }
        // remove all "Set-Cookie" headers, `header_remove()` is case
        // insensitive
        $this->header->remove('Set-Cookie');

        // restore cookies we want to keep
        foreach ($cookieList as $cookie) {
            $this->header->set($cookie, false);
        }

        $this->set($name, $value);
    }