Home  >  Article  >  Backend Development  >  Problem with setcookie statement_PHP tutorial

Problem with setcookie statement_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:35:53698browse

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:
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.……

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.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/508261.htmlTechArticleError message: Warning: Cannot modify header information - headers already sent by Solution: Open php_ini and search for output_bufferfing , remove the semicolon in front and modify off...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn