For example: The following is the quoted content: You will find that after this statement is executed, there is nothing in the cookie. When you go to the next page, it will be displayed that there is no value of the COOKIE variable $USERID. First of all, the value of "Cookie expiration time" set in the browser process is not the current Unix timestamp + 0. If it is set to the browser process, just set the expiration time to 0 directly. The above program may work if you write it like this: The following is the quoted content: There will be no output when you open this page for the first time, because the cookie will not take effect immediately on the current page.
$USERID="PHPer";
$CookieTime=0;
setcookie("USERID", "$USERID", time( )+$CookieTime,"/","pcpchina.com");
?>
The problem analysis is as follows:
Secondly, I don’t know what domain name you used when testing this page. If you set "pcpchina.com", it means that you must use "pcpchina.com" to access the cookie for it to be effective. In fact, if your If there are many domain names to access this page, then this place can be empty or the domain names accessing this cookie are all under the same domain, then set it to ".pcpchina.com", remember there is a "dot" in front of it
$USERID="PHPer";
$CookieTime=0;
setcookie("USERID","$USERID",0, "/","");
echo(isset($_COOKIE[USERID])?$_COOKIE[USERID]:);
?>
It will be displayed after refreshing.