Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
好吧,我想在自定义日期执行 Cookie Expires,例如明天(08-16):
setcookie("Cookie_name", "Cookie_value", time()+86400);
但是如果我访问网络(08-17),cookie 将在 08-18 到期
如何使 cookie 在自定义日期过期?
用于strtotime()为您想要的日期制作时间戳:
strtotime()
setcookie("Cookie_name", "Cookie_value", strtotime('2013-08-16'));
或者:-
setcookie("Cookie_name", "Cookie_value", (new \DateTime)->modify('tomorrow')->getTimestamp();