Symfony\Component\HttpFoundation\Response::sendHeaders PHP Method

sendHeaders() public method

Sends HTTP headers.
public sendHeaders ( ) : Response
return Response
    public function sendHeaders()
    {
        // headers have already been sent by the developer
        if (headers_sent()) {
            return $this;
        }

        if (!$this->headers->has('Date')) {
            $this->setDate(\DateTime::createFromFormat('U', time()));
        }

        // headers
        foreach ($this->headers->allPreserveCaseWithoutCookies() as $name => $values) {
            foreach ($values as $value) {
                header($name.': '.$value, false, $this->statusCode);
            }
        }

        // status
        header(sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText), true, $this->statusCode);

        // cookies
        foreach ($this->headers->getCookies() as $cookie) {
            if ($cookie->isRaw()) {
                setrawcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly());
            } else {
                setcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly());
            }
        }

        return $this;
    }

Usage Example

 public function frontendResetAction($id = false)
 {
     $response = new Response();
     $response->headers->setCookie(new Cookie("subscriber_id", false));
     $response->sendHeaders();
     return $this->redirect($this->generateUrl('subscriber_frondend_submit', array('id' => $id)));
 }
All Usage Examples Of Symfony\Component\HttpFoundation\Response::sendHeaders