Home > Backend Development > PHP Tutorial > Explanation of headersalreadysent error when using session_start_PHP Tutorial

Explanation of headersalreadysent error when using session_start_PHP Tutorial

WBOY
Release: 2016-07-20 11:03:52
Original
939 people have browsed it

Please see the detailed error program and output results

echo "testing ... ";
session_start();
?>
< ;/html>
The output is
testing ...
Warning: Cannot send session cookie - headers already sent by (output started at F:php2000test.php:2) in F:php2000test.php on line 4
Warning: Cannot send session cache limiter - headers already sent (output started at F:php2000test.php:2) in F:php2000test.php on line 4
Analysis:
Main reason, php.ini There is a definition of session. The default is to use cookies
[session]
session.use_cookies = 1; whether to use cookies
indicates that cookies are used to store sessions and the settings of cookies must be before the official htm. That is to say, it can only work in the header, so when this error occurs
we modify the program to
echo "testing ... ";
session_start();
?>
The same error, because echo has output
We modify the program to
$i=1;
session_start();
?>
Correct operation shows that there can be calculation statements in front of session_start, but there cannot be output statements
I tried to modify
session.use_cookies = 0; whether to use cookies
but it was not successful. Friends who hope to know the answer Notify me how to remove the cookie session

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445251.htmlTechArticlePlease see the detailed error program and output results html ? echo testing ... ; session_start(); ? /html The output is testing... Warning: Cannot send session cookie - headers already sent by (ou...
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