Home >Backend Development >PHP Tutorial >Problem with setcookie statement_PHP tutorial
Error message: Warning: Cannot modify header information - headers already sent by Solution: Open php_ini, search for output_bufferfing, remove the semicolon in front, change off to on, or set a value. That's it. This type of statement causes this problem because of the problem of the setcookie statement. There are some restrictions on the use of cookies, such as: Based on the above restrictions, when executing the setcookie() function, you often encounter "Undefined index", "Cannot modify header information - headers already sent by"..., etc., the solution is "Cannot modify header information" The method of "-headers already sent by" is to delay the output of data to the browser before generating a cookie. Therefore, you can add the ob_start(); function at the front of the program. This will solve it.
1. The command to call setcookie must be placed before the label
2. Before calling setcookie, echo cannot be used
3. Until?? After being re-entered, the cookie will be saved in the program.
4. The setcookie function must be sent before any data is sent to the browser
5.……