Why does the cookie settings fail? I have a program like this: if (setcookie ('me', 'mycookie ') {echo & nbsp; "cookie set";} echo & nbsp; "logged on "; the running result is "logged on", but "cookie set" is not displayed. This indicates why the cookie setting fails?
I have such a program:
If (setcookie ('me', 'mycooker '))
{
Echo "cookie set ";
}
Echo "logged on ";
The running result is "logged on", but "cookie set" is not displayed. This indicates that the cookie settings failed.
Why can't I set this program? Is there a syntax error? What are the possible causes of failure? (My browser supports cookies:
------ Solution --------------------
Setcookie () defines a cookie sent together with other HTTP headers. Like other headers, cookies must be sent before any other output of the script (this is a protocol restriction ). This requires that the call of this function be placed before any output, including, labels, and any spaces. If any output exists before setcookie () is called, this function fails and returns FALSE. If the setcookie () function runs successfully, TRUE is returned.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service