Quick question: how to set a cookie that expires after 90 days in PHP?

I want to set a cookie that expires in 90 days using PHP, how can I do this? Thanks in advance.

+3
source share
5 answers
setcookie(name, value, time()+60*60*24*90); 

This will set the cookie for 90 days.

+5
source

Cookies expire in seconds: 60 * 60 * 24 * 90 - 90 days.

setcookie("MyCookie", $value, time()+(60*60*24*90)); 
+2
source

Use this:

setcookie('name', 'value', strtotime('NOW+90DAYS'));
+1
source
setcookie('cookie_name', 'cookie_value', time() + 7776000);

Check out the documentation for more details - http://php.net/manual/en/function.setcookie.php

+1
source
setcookie("TestCookie", $value, time()+7776000); 
0
source

Source: https://habr.com/ru/post/1773959/


All Articles