Php provides a complete solution to the Cannotmodifyheaderinformation problem. Obviously, this is because of setcookie. I checked the Internet and explained the following: the cookie itself has some restrictions, for example: 1. the reason for calling the setcookie statement is obviously due to the setcookie. I checked the Internet and explained the following: the cookie itself has some restrictions, for example:
1. descriptions of the call setcookie must be placed inBefore tag
2. you cannot use echo before calling setcookie.
3. the cookie will not appear in the program until the website is reinjected.
4. the setcookie function must be sent out before any information is sent to the browser.
5 .......
Based on the above restrictions, when setting the setcookie () function, we often encounter "Undefined index", "Cannot modify header information-headers already sent "... To solve the problem, the solution "Cannot modify header information-headers already sent by" is to delay the data output to the browser before the cookie is generated. therefore, you can add ob_start (); at the beginning of the program. This will solve the problem. If you want to add ob_start (), it is not feasible. it seems a little depressing that the program has been written .. when I found this error, I was wondering why I didn't prompt this problem locally. I thought it was PHP. the ini configuration is different. if you think it's wrong, it's almost the same ..
So let's look at the sentence "output started .... "It means that there is another output before setcookie, so find the file followed by output started at and check that the first line is blank. Solution complete!
Solution 2:
There are many ways to solve this problem on the Internet, but today we have encountered this problem. After the test, we found it feasible:
Find the configuration file php. ini in WINDOWS on drive C, and then find the item: output_buffering, change its value from the original off to on, and restart Apache.
Response 1. call setcookie...