public function addCookieObject(Cookie $cookie)
    {
        $name = $cookie->getName();
        $isNew = true;
        foreach ($this->cookies as $index => $value) {
            if ($value->getName() === $name) {
                $this->cookies[$index] = $cookie;
                $isNew = false;
            }
        }
        if ($isNew) {
            $index = array_search($name, $this->clearedCookies, true);
            if ($index !== false) {
                unset($this->clearedCookies[$index]);
                $this->clearedCookies = array_values($this->clearedCookies);
            }
            $this->cookies[] = $cookie;
        }

        return $this;
    }