When you do a project, you need to prepare a unified error prompt function. Small series in function execution, first deal with the wrong address to write cookies to facilitate the user login can jump directly to the implementation of this page, but found in the server test, unexpectedly prompts local error: Warning: Cannot modify header information-headers already sent by .... Such a statement, it is obvious that this reason is caused by setcookie, look up the internet, like the explanation: the cookie itself in the use of a number of restrictions, such as:
1. Syria of call Setcookie must be placed in 2. Before calling Setcookie, you cannot use echo
3. Cookies will not appear in the program until the web is uploaded
4. The Setcookie function must send before any data is output to the browser.
is based on these limitations, so when you perform the Setcookie () function, you will often encounter the Undefined index, cannot modify header information-headers already sent by. To solve the problem, "cannot modify header Information-headers already sent by" is the wrong way to slow down the data output to the browser before creating cookies, so you can add ob_ to the front of the program Start (): this function. This will solve the problem. If you want to add Ob_start (), it is not feasible, the procedures have been written, just to change this seems a bit depressing. Found that prompted this error, I was thinking about how the local did not prompt this question, but also thought that the php.ini configuration is not the same, think again is not the same. &NBSP
Then look at the following sentence "output started at ..." means that there is already an output in another place before Setcookie, and then find the file at the back of output started, see the first line is blank, and then the <?php start like this, is this the problem of this line?? I also have this line locally, remove, refresh and try again, oh, sure enough out here, no longer prompt warning.
Finish!
Workaround Two:
There are many ways to find solutions to this problem on the Internet, but today it is a problem. After a trial, it was found to be feasible:
Locate php.ini this profile in Windows C, and then look for an item: output_buffering change its value from the original off to on, and restart Apache OK.