File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -402,6 +402,7 @@ And here is the controller::
402402 use Lcobucci\JWT\Signer\Hmac\Sha256;
403403 use Lcobucci\JWT\Signer\Key;
404404 use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
405+ use Symfony\Component\HttpFoundation\Cookie;
405406 use Symfony\Component\HttpFoundation\Request;
406407 use Symfony\Component\HttpFoundation\Response;
407408 use Symfony\Component\WebLink\Link;
@@ -419,10 +420,14 @@ And here is the controller::
419420 ->getToken(new Sha256(), new Key($this->getParameter('mercure_secret_key'))); // don't forget to set this parameter! Test value: !ChangeMe!
420421
421422 $response = $this->json(['@id' => '/demo/books/1', 'availability' => 'https://schema.org/InStock']);
422- $response->headers->set(
423- 'set-cookie',
424- sprintf('mercureAuthorization=%s; path=/.well-known/mercure; secure; httponly; SameSite=strict', $token)
425- );
423+ $cookie = Cookie::create('mercureAuthorization')
424+ ->withValue($token)
425+ ->withPath('/.well-known/mercure')
426+ ->withSecure(true)
427+ ->withHttpOnly(true)
428+ ->withSameSite('strict')
429+ ;
430+ $response->headers->setCookie($cookie);
426431
427432 return $response;
428433 }
You can’t perform that action at this time.
0 commit comments