Home>Article>Backend Development> How to set the cookie validity period in php to close the browser process?

How to set the cookie validity period in php to close the browser process?

coldplay.xixi
coldplay.xixi Original
2020-07-24 11:55:36 2164browse

How to set the cookie validity period in php to close the browser process: first use the setCookie method to set hours to an empty string; then set hours to empty in the same way in php; and finally set hours to 0.

How to set the cookie validity period in php to close the browser process?

#php method to set the cookie validity period to close the browser process:

Use the setCookie method and set hours to empty String, the cookie's lifetime will end after the browser session

function setCookie(name,value,hours,path){}

I also want to set it in PHP like this

setCookie("lastime",$selectlogin['lastime'],0,'/');

Set hours to be empty, but an error was reported, and then I set hours to 0. This cookie is valid for as long as the browser process.

Related learning recommendations:PHP programming from entry to proficiency

The above is the detailed content of How to set the cookie validity period in php to close the browser process?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn