简体   繁体   中英

when this cookie will expire if we specify the time 3600?

when this cookie will expire?

setcookie( 'MY_BLOG', 1, 3600, '/' );

Need time() + 3600 compulsory?

when this cookie will expire if we specify the time 3600?

It will have been expired even before you set it then, because 3600 seconds from UNIX Epoch have long gone, your cookie will never work. Precisely this cookie is set to expire on 1970-01-01 01:00:00

Need time() + 3600 compulsory?

Yes it is if you want cookie to expire in 1 hour from now. If you don't provide this value then the cookie will automatically expire when the current session is terminated. See

expire

The time the cookie expires. This is a Unix timestamp so is in number of seconds since the epoch . In other words, you'll most likely set this with the time() function plus the number of seconds before you want it to expire. Or you might use mktime(). time()+60*60*24*30 will set the cookie to expire in 30 days. If set to 0, or omitted, the cookie will expire at the end of the session (when the browser closes).

(emphasis mine)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM