AppserverIo\Appserver\ServletEngine\Http\Response::addCookie PHP Method

addCookie() public method

Adds a cookie.
public addCookie ( AppserverIo\Psr\HttpMessage\CookieInterface $cookie ) : void
$cookie AppserverIo\Psr\HttpMessage\CookieInterface 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;
        }
    }