/** * Adds a cookie. * * @param \AppserverIo\Psr\HttpMessage\CookieInterface $cookie The cookie instance to add * * @return void */ public function addCookie(CookieInterface $cookie) { // check if this cookie has already been set if ($this->hasCookie($name = $cookie->getName())) { // then check if we've already one cookie header available if (is_array($cookieValue = $this->getCookie($name))) { $cookieValue[] = $cookie; } else { $cookieValue = array($cookieValue, $cookie); } // add the cookie array $this->cookies[$name] = $cookieValue; } else { // when add it the first time, simply add it $this->cookies[$name] = $cookie; } }
/** * Adds the cookie by name to the cookies array * * @param CookieInterface $cookie The cookie object * * @return void */ public function addCookie(CookieInterface $cookie) { // add's the cookie by name to the cookies array $this->cookies[$cookie->getName()] = $cookie; }