I am trying to set a cookie in a symfony2 project.
Everything is working fine, except that the cookie is deleted once the browser is closed. I tried to set an expiration time but it throws an error : Expiry date cannot have a year greater then 9999
How can I fix it?
Here is my code:
$time = time() * 3600 * 24 * 7;
$response = new Response();
$response->headers->setCookie(new Cookie('lang', $lang, $time));
$response->send();
Your
$timecalculation should be