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::
402
402
use Lcobucci\JWT\Signer\Hmac\Sha256;
403
403
use Lcobucci\JWT\Signer\Key;
404
404
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
405
+ use Symfony\Component\HttpFoundation\Cookie;
405
406
use Symfony\Component\HttpFoundation\Request;
406
407
use Symfony\Component\HttpFoundation\Response;
407
408
use Symfony\Component\WebLink\Link;
@@ -419,10 +420,14 @@ And here is the controller::
419
420
->getToken(new Sha256(), new Key($this->getParameter('mercure_secret_key'))); // don't forget to set this parameter! Test value: !ChangeMe!
420
421
421
422
$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);
426
431
427
432
return $response;
428
433
}
You can’t perform that action at this time.
0 commit comments