Home  >  Article  >  Backend Development  >  About headers appearing using session_start _PHP tutorial

About headers appearing using session_start _PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:53:29923browse

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/632399.htmlTechArticlePlease see the detailed error program and output results html ? echo "testing ... "; session_start(); ? /html output is testing... Warning: Cannot send session cookie - headers already sent by (...
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