


Explanation of headersalreadysent error when using session_start_PHP Tutorial
Jul 20, 2016 am 11:03 AM
Please 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 (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

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Unable to complete operation (Error 0x0000771) Printer error

What software is crystaldiskmark? -How to use crystaldiskmark?

Solution to Windows Update prompt Error 0x8024401c error

How to download foobar2000? -How to use foobar2000

Teach you how to use the new advanced features of iOS 17.4 'Stolen Device Protection'

BTCC tutorial: How to bind and use MetaMask wallet on BTCC exchange?
