I want to use header() function to set a cookie with 30 day expiry time as shown below:
$exptime=time()+30*24*60*60;
header("Set-Cookie: __try1=usingheader; expires=$exptime; path=/");
But this doesn't work and just sets a session cookie. The same thing works fine with setcookie() function
setcookie("__try2", "usingsetcookie", $exptime, '/');
The response headers are as below:
Set-Cookie: __try1=usingheader; expires=1613126399; path=/
Set-Cookie: __try2=usingsetcookie; expires=Fri, 12-Feb-2021 10:39:59 GMT; Max-Age=2592000; path=/
Would appreciate any help on this.