Php cannot save cookies.

Source: Internet
Author: User
Tags wordpress blog
Php cannot save cookies to solve the problem of getting the php program today. suddenly, a problem occurs, that is, cookies cannot be saved without any errors. the following problems are found after some searches: because the program is using Cookies? @ Setcookie ("url", "http: // www. my40080 php cannot save cookies.

When I got a php program today, I suddenly found a problem: cookies cannot be saved and no errors occur. after some searches, I found the problem as follows:

Because the program is using Cookies? @ Setcookie ("url", "http://www.my400800.cn", time () + 3600*24 ,"/");

The meaning of the @ and # symbol in PHP

Function foo ($ n)
{
??? $ Result = 1/$ n;
??? Return $ result;
}
Echo @ foo (0); // The function generates an error except 0, but this error is not displayed after @ is added.
Echo "end"; // output end

# Annotator

Same as //, # is a single line annotator (multiline Annotator is /**/).

Because @ setcookie is used, even if an error occurs when the cookie is written, no output is generated, leading to the failure to detect the problem. Finally, Change @ setcookie to setcookie, and the program outputs the following error message:

Warning: Cannot modify header information-headers already sent by (output started

After checking the internet, I found that there was no output content before setting the setcookie. then I checked the code and did not find anything output before the setcookie. I searched for it, the problem is found. The details are as follows:

?

Today, I visited the WordPress Chinese forum. The popularity in the jar is not high, but there are still many masters. The experts who will write plug-ins and templates and beginners who cannot even edit files will not be mixed together. this is the case in the forum, haha.

Several posts mentioned the same error, as mentioned in this post: "Warning: Cannot modify header information-headers already sent by (output started at c: \ program files \ easyphp1-8 \ www \ wp-config.php: 1) in c: \ program files \ easyphp1-8 \ www \ wp-login.php on line 9"

This is a typical problem. When a WordPress program is executed, it first calls a configuration file such as the wp-config.php, and also calls the wp-db.php to establish a database connection for later use. These files only make some settings and do not output html code. After the settings are complete, the program itself starts to execute. some programs will use the header command to set an HTTP header. Because the HTTP header must be set before html code output, otherwise the html code has already been sent to the client, and HTTP has already been sent and cannot be recovered. WordPress CodeX explained this problem: How do I solve the Headers already sent warning problem? The article states that it is necessary to ensure that each file, especially the frequently edited wp-config.php file It cannot end with any other character. Specifically to the above example, it is obvious that the prompt information says the first line of the wp-config.php begins the html output, which may be the first line

?

Solution

The WordPress Chinese forum does not provide the full-text search function, so I can only search for titles. so I used Google to search for Cannot modify header information site: wordpress.org.cn. it seems that many people have encountered this problem. At present, WordPress is mainly used in the original WordPress English version and several WordPress Chinese versions. My Chinese package does not contain wp-config-sample.php files, naturally none of my business; the original WordPress ASCII code, naturally does not contain BOM, will not make such an error; the Chinese version of WordPress made by xigang is available in the WordPress Chinese forum. I downloaded WordPress 2.0.4 and 2.0.3 and checked them. there is no problem. in the Chinese version of WordPress 2.0.4, the wp-config-sample.php file uses GB2312 encoding and DOS line tail, GOD! However, if someone uses notepad to modify the file, the DOS line tail will not cause editing problems, and GB2312 encoding will not cause BOM problems.

Alas, if you want to use the WordPress Blog, you should discard the notepad and install UltraEdit or EditPlus!

?

?

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.