How can I set the path when setcookie does not set the expiration time?
How can I set the path when setcookie does not set the expiration time?
The following write methods do not take effect:
setcookie(mycookie,'11','','/'); setcookie(mycookie,'11',,'/'); setcookie(mycookie,'11','/');
But write it like this:
setcookie(mycookie,'11',time()+31104000,'/');
But I don't want to point to the expiration time. I want to delete the COOKIE as soon as I close the browser.
I did not know how to write this case after reading the online tutorials.
Who can help me? thank you!
Reply to discussion (solution)
Use session
I want to use cookies, right?
Or
setcookie("mycookie", '11');setcookie("mycookie", '11');
In this way, the directory cannot be specified.
setcookie('mycookie','11',0,'/');
Is it clear in the manual?
Because the expire parameter is an integer, it cannot be replaced by zero (0 ).
Thank you for your answers :)
The preceding figure shows how to set the expiration time for setcookie without setting the path? For more information, see The PHP Chinese website (www.php1.cn )!
Related articles:
PHP setcookie usage
The php setcookie function is invalid.
Cookie setting PHP setcookie setting Cookie usage and invalid settings