// this will be the HTTP header added for the cookie:

// Assuming that the current time is "Wed, 28-Dec-2016 15:00:00 +0100",

Starting with PHP 5.5, the setcookie() and setrawcookie() functions send the Max-Age attribute alongside Expires when a Set-Cookie header is created. That's why in Symfony 3.3, cookies will start including the max-age attribute:

Creating cookies with strings¶

In Symfony 3.3, cookies can be created using strings thanks to the new Cookie::fromString() named constructor:

1 2 3 4 5 6 7 use Symfony\Component\HttpFoundation\Cookie ; // Creating cookies with arguments $cookie = new Cookie ( 'foo' , 'bar' , strtotime ( 'Wed, 28-Dec-2016 15:00:00 +0100' ), '/' , '.example.com' , true , true , true ), // Creating cookies with a string $cookie = Cookie :: fromString ( 'foo=bar; expires=Wed, 28-Dec-2016 15:00:00 +0100; path=/; domain=.example.com; secure; httponly' );

You can also use strings to add cookies to the response headers: