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

Jul 20, 2016 am 11:03 AM
session start use about Appear of explain mistake

Please see the detailed error program and output results
<html>
<?
echo "testing ... ";
session_start();
?>
&lt ;/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...
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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Unable to complete operation (Error 0x0000771) Printer error Unable to complete operation (Error 0x0000771) Printer error Mar 16, 2024 pm 03:50 PM

Unable to complete operation (Error 0x0000771) Printer error

What software is crystaldiskmark? -How to use crystaldiskmark? What software is crystaldiskmark? -How to use crystaldiskmark? Mar 18, 2024 pm 02:58 PM

What software is crystaldiskmark? -How to use crystaldiskmark?

Solution to Windows Update prompt Error 0x8024401c error Solution to Windows Update prompt Error 0x8024401c error Jun 08, 2024 pm 12:18 PM

Solution to Windows Update prompt Error 0x8024401c error

How to download foobar2000? -How to use foobar2000 How to download foobar2000? -How to use foobar2000 Mar 18, 2024 am 10:58 AM

How to download foobar2000? -How to use foobar2000

How to use Baidu Netdisk app How to use Baidu Netdisk app Mar 27, 2024 pm 06:46 PM

How to use Baidu Netdisk app

How to use NetEase Mailbox Master How to use NetEase Mailbox Master Mar 27, 2024 pm 05:32 PM

How to use NetEase Mailbox Master

Teach you how to use the new advanced features of iOS 17.4 'Stolen Device Protection' Teach you how to use the new advanced features of iOS 17.4 'Stolen Device Protection' Mar 10, 2024 pm 04:34 PM

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? BTCC tutorial: How to bind and use MetaMask wallet on BTCC exchange? Apr 26, 2024 am 09:40 AM

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

See all articles