Skip to content

Set Cookie for PSR 7

sunrise-php edited this page Jan 7, 2019 · 1 revision

Install Sunrise Header Kit

Learn more about Sunrise Header Kit

composer require sunrise/http-header-kit

Using

use Sunrise\Http\Header\HeaderSetCookie;

public function process(
    ServerRequestInterface $request,
    RequestHandlerInterface $handler) : ResponseInterface
{
    // some code

    $header = new HeaderSetCookie('foo', 'bar', new \DateTime('+1 hour'));
    $response = $header->addToMessage($response);

    // some code
}