PHP sets the COOKIE retention time as the browser process, and read the PHP setting the COOKIE retention time as the browser process. for example, the following is the reference content :? Php $ USERID = "> <LINKhref =" http://www.php100.com//statics/style/headfloor_950_081205.css "type = text/cs
For example:
Reference content is as follows:
$ USERID = "PHPer ";
$ CookieTime = 0;
Setcookie ("USERID", "$ USERID", time () + $ CookieTime, "/", "pcpchina.com ");
?>
You will find that after the statement is executed, there is nothing in the Cookie. the COOKIE variable value $ USERID is displayed on the next page.
The problem is analyzed as follows:
First, set the "Cookie expiration time" of the browser process. this value is not the current Unix timestamp + 0. if it is set to a browser process, set the Expiration Time to 0.
Secondly, it is unclear what the domain name is when you test this page. if you set "pcpchina.com", it means that you must use "pcpchina.com" to access the cookie to make it valid, in fact, if many of your domain names access this page, the domain name that can be empty or access this cookie is under the same domain, then set it to ".pcpchina.com ", remember that there is a "dot" in front"
The above program may be valid if you write it like this:
Reference content is as follows:
$ USERID = "PHPer ";
$ CookieTime = 0;
Setcookie ("USERID", "$ USERID", 0 ,"/","");
Echo (isset ($ _ COOKIE ['userid'])? $ _ COOKIE ['userid']: '');
?>
When this page is opened for the first time, no output is generated because the cookie does not take effect immediately on the current page.
It will be displayed after refresh.