Setting Cookie variable in a Controller - Symfony2 Setting Cookie variable in a Controller - Symfony2 symfony symfony

Setting Cookie variable in a Controller - Symfony2


The cookie object has httpOnly set to true by default, http://api.symfony.com/2.0/Symfony/Component/HttpFoundation/Cookie.html

This means that the browser should not make the cookie visible to client-side scripts. If you need to see the cookie in your scripts you can pass the 7th parameter as false when you create the cookie.

$response->headers->setCookie(new Cookie('foo', 'bar',time() + 60, '/', null, false, false));

If you just need to view the cookie for debugging purposes you can use Chrome Dev tools. They are available under the 'Resources' tab.