For example:
The following are the referenced contents:
<?php
$USERID="PHPer";
$CookieTime=0;
setcookie("USERID", "$USERID", time()+$CookieTime,"/","pcpchina.com");
?>
You will find that after this statement is executed, there is nothing in the cookie, and the next page shows no $userid the cookie variable value.
The analysis of the problem is as follows:
First, setting the "Cookie Expiration Time" value for the browser process is not the current UNIX timestamp +0, and if it is set to the browser process, the expiration time is set to 0 directly.
Second, it is not clear you test this page when the domain name is used, if you set the "pcpchina.com", it means that you must use "pcpchina.com" to access cookies will be effective, in fact, if your domain name a lot of access to this page, So this place can be empty or the domain name that accesses this cookie is below a domain, then set to ". Pcpchina.com", Remember "dot" in front.
The above procedure, if you write this, may be effective:
The following are the referenced contents:
<?php
$USERID="PHPer";
$CookieTime=0;
setcookie("USERID","$USERID",0,"/","");
echo(isset($_COOKIE['USERID'])?$_COOKIE['USERID']:'');
?>
The first time you open this page, there will be no output, because the cookie does not take effect immediately on the current page.
will be displayed after the refresh.