Search code examples
cookiestypo3typo3-10.xpsr-7

How to add a cookie when using TYPO3 Middleware?


I want to use the Middleware to add a cookie.

In TYPO3 I have the Psr\Http\Message\ServerRequestInterface $request and the Psr\Http\Server\RequestHandlerInterface $handler variables.

What is the best practise to add a cookie with all the needed settings (secure, domain, expire)?


Solution

  • There is no explicit interface in PSR for this since it basically boils down to sending a Set-Cookie header in the $response. You can either build that header yourself or use some packages which do this for you: