English 中文(简体)
Cookie 饼干过期, Symonfy 2 不工作
原标题:Cookie expiration not working on Symonfy 2

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

我怎样才能修好它?

这是我的代码:

$time = time() * 3600 * 24 * 7;
$response = new Response();
$response->headers->setCookie(new Cookie( lang , $lang, $time));
$response->send();
最佳回答

您的 $$time 计算应该是

$time = time() + (3600 * 24 * 7);
问题回答

暂无回答




相关问题
How to suppress/remove PHP session cookie

I need to suppress an already set session cookie header, but I cannot find any way to do this. Why? I need to make an image, sent by a PHP script, cacheable by the end user; this image is used to ...

Remove Cookies from JS or CSS files

Bizarrely my javascript and css files have cookies (says Firebug). I use Zend Framework and I think it has to do with it. Could I change the .htaccess that CSS or JS files don t link to the ZF or is ...

httplib2, how to set more than one cookie?

As you are probably aware, more often than not, an HTTP server will send more than just a session_id cookie; however, httplib2 handles cookies with a dictionary, like this: response, content = http....

cookies control

what tool wold you recommend me to use in order to see what data are stored in my cookies while i m browsing the net. I m a beginner into webdev field(6 months php experience) and i m curious to see ...

热门标签