For example:
Copy CodeThe code is as follows:
$USERID = "Phper";
$CookieTime = 0;
Setcookie ("USERID", "$USERID", Time () + $CookieTime, "/", "btcuxiao.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 problem analysis is as follows:
First of all, set the browser process's "Cookie Expiration Time" value is not the current UNIX timestamp +0, if set as a browser process, the expiration time is set to 0.
Secondly, it is unclear what domain name you used when testing this page, if you set up "btcuxiao.com", it means that you must use "btcuxiao.com" to access the cookie 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 a domain below, then set to ". Btcuxiao.com", Remember "dot" in front
The above program may work if you write this:
Copy CodeThe code is as follows:
$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.
The refresh will be displayed later.
http://www.bkjia.com/PHPjc/320178.html www.bkjia.com true http://www.bkjia.com/PHPjc/320178.html techarticle For example: Copy code code as follows: PHP $USERID = "Phper"; $CookieTime =0; Setcookie ("USERID", "$USERID", Time () + $CookieTime, "/", " Btcuxiao.com ");? You will find that after this statement is executed ...