& Amp; lt ;? Php {code ...} why is an error reported during the first execution of this Code? Notice: Undefinedindex: nameinD: wampApachehtdocstest will be reported. phponline10 has an undefined index name. I set the COOKIE before reading it? For details...
setcookie('name',234,time()+10,'/');//$b = $_COOKIE['name'];echo $_COOKIE['name'];
Why is an error reported during the first execution of this code?
Notice: Undefined index: name in D: \ wamp \ Apache \ htdocs \ test. php on line 10
For an undefined index name, I set the COOKIE before reading it? Explanation
Reply content:
setcookie('name',234,time()+10,'/');//$b = $_COOKIE['name'];echo $_COOKIE['name'];
Why is an error reported during the first execution of this code?
Notice: Undefined index: name in D: \ wamp \ Apache \ htdocs \ test. php on line 10
For an undefined index name, I set the COOKIE before reading it? Explanation
The cookie setting does not take effect immediately,setcookie()Add the following content to the response header:Set-CookieHeader, for example:
Set-Cookie: PHPSESSID=tbmh6ussjmqrblhth75qb9h2l0; path=/
The response arrives at the client. After the Cookie is set successfully, the next request from the client will include this Header in the Header:
Cookie: PHPSESSID=tbmh6ussjmqrblhth75qb9h2l0
In this case$_COOKIEObtain this value. This is why:
they can be accessed on the next page load with the $_COOKIE or $HTTP_COOKIE_VARS
Once the cookies have been set, they can be accessed on the next page load with the $_COOKIE or $HTTP_COOKIE_VARS
Php description of the setcookie function.