Home > Backend Development > PHP Tutorial > Warning: session_start() [function.session-start]: Cannot se_PHP教程

Warning: session_start() [function.session-start]: Cannot se_PHP教程

WBOY
Release: 2016-07-13 10:55:00
Original
1001 people have browsed it

If you use session for a long time, the following prompt will appear,

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/u114264/include/db_mysqltutorial.class.phptutorial:1) in /home/ u114264/login1.php on line 3

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/u114264/include/db_mysql.class.php:1) in /home/u114264/ login1.php on line 3

The most likely analysis is that there are characters output including spaces in front of session_start(). Just deal with it,

There is another way to directly add @session_start() to session_start() and it will be fine. Not recommended

Address solution.


The most common solution. Turn on output_buffering = 4096; global property.

Second solution.


ob_start: Open the output buffer
Function format: void ob_start(void)
Note: When the buffer is activated, all non-file header information from the PHP program will not be sent, but will be saved in the internal buffer. In order to output the contents of the buffer, you can use ob_end_flush() or flush() to output the contents of the buffer.

Points to note:


If you use utf-8 encoding, you must remove the BOM in UTF-8. This is because the utf-8 encoded file contains BOM, and php4 and 5 do not support BOM. To remove the BOM, you can open it with Notepad++ and convert it.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632290.htmlTechArticleIf you use session for a lot of time, the following prompt will appear, Warning: session_start() [function.session-start ]: Cannot send session cookie - headers already sent by (output starte...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template