473,757 Members | 9,463 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Header already sent

Hi everybody,
I am working with site development with PHP.

My problem is I have made a header file of header.inc . I use php
function for session start but I when I to to php file for some
validation and come to same page the error is come that Header already
sent....

"Warning: session_start() [function.sessio n-start]: Cannot send
session cache limiter - headers already sent ...."

I don't know how can I handle with this error.
Thankyou in advance.
situ

Jun 21 '07 #1
9 3258
up********@gmai l.com ha scritto:
"Warning: session_start() [function.sessio n-start]: Cannot send
session cache limiter - headers already sent ...."
I don't know how can I handle with this error.
I experienced the same warning when I use the header() function after
output-ing some text e.g.

echo("<html>");
header("Content-Type: text/html");

Try to check if you have the same situation.

--
|\/|55: Mattia Gentilini e 55 GMG
|/_| ETICS project at CNAF, INFN, Bologna, Italy
|\/| www.getfirefox.com www.getthunderbird.com
* Using Mac OS X 10.4.10 powered by Cerebros (Core 2 Duo) *
Jun 21 '07 #2
On Jun 21, 3:00 pm, Mattia Gentilini
<Mattia.Gentili ni_REMOVE_@_REM OVE_CNAF.INFN.I Twrote:
upendra...@gmai l.com ha scritto:"Warnin g: session_start() [function.sessio n-start]: Cannot send
session cache limiter - headers already sent ...."
I don't know how can I handle with this error.

I experienced the same warning when I use the header() function after
output-ing some text e.g.

echo("<html>");
header("Content-Type: text/html");

Try to check if you have the same situation.

--
|\/|55: Mattia Gentilini e 55 GMG
|/_| ETICS project at CNAF, INFN, Bologna, Italy
|\/|www.getfirefox.com www.getthunderbird.com
* Using Mac OS X 10.4.10 powered by Cerebros (Core 2 Duo) *


Thank you very much for giving prompt reply .. I tried as you write
but It cann't work and I remove my header.inc and use
<? session_start() ; ?top of my html page but eroor is still

"Warning: session_start() [function.sessio n-start]: Cannot send
session cookie - headers already sent by (output started at C:\Program
Files\Apache Software Foundation\Apac he2.2\htdocs\ra jput_new
\loginform.html :2) in "
situ

Jun 21 '07 #3
up********@gmai l.com wrote:
On Jun 21, 3:00 pm, Mattia Gentilini
<Mattia.Gentili ni_REMOVE_@_REM OVE_CNAF.INFN.I Twrote:
>upendra...@gma il.com ha scritto:"Warnin g: session_start() [function.sessio n-start]: Cannot send
>>session cache limiter - headers already sent ...."
I don't know how can I handle with this error.
I experienced the same warning when I use the header() function after
output-ing some text e.g.

echo("<html>") ;
header("Conten t-Type: text/html");

Try to check if you have the same situation.

--
|\/|55: Mattia Gentilini e 55 GMG
|/_| ETICS project at CNAF, INFN, Bologna, Italy
|\/|www.getfirefox.com www.getthunderbird.com
* Using Mac OS X 10.4.10 powered by Cerebros (Core 2 Duo) *

Thank you very much for giving prompt reply .. I tried as you write
but It cann't work and I remove my header.inc and use
<? session_start() ; ?top of my html page but eroor is still

"Warning: session_start() [function.sessio n-start]: Cannot send
session cookie - headers already sent by (output started at C:\Program
Files\Apache Software Foundation\Apac he2.2\htdocs\ra jput_new
\loginform.html :2) in "
situ
From the manual at
<http://us2.php.net/manual/en/function.sessio n-start.php>

"If you are using cookie-based sessions, you must call session_start()
before anything is outputted to the browser."

You can output absolutely nothing before the call to session_start - no
DOCTYPE, no tags, not even any white space.
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Jun 21 '07 #4
On Jun 21, 4:43 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
upendra...@gmai l.com wrote:
On Jun 21, 3:00 pm, Mattia Gentilini
<Mattia.Gentili ni_REMOVE_@_REM OVE_CNAF.INFN.I Twrote:
upendra...@gmai l.com ha scritto:"Warnin g: session_start() [function.sessio n-start]: Cannot send
session cache limiter - headers already sent ...."
I don't know how can I handle with this error.
I experienced the same warning when I use the header() function after
output-ing some text e.g.
echo("<html>");
header("Content-Type: text/html");
Try to check if you have the same situation.
--
|\/|55: Mattia Gentilini e 55 GMG
|/_| ETICS project at CNAF, INFN, Bologna, Italy
|\/|www.getfirefox.comwww.getthunderbird.com
* Using Mac OS X 10.4.10 powered by Cerebros (Core 2 Duo) *
Thank you very much for giving prompt reply .. I tried as you write
but It cann't work and I remove my header.inc and use
<? session_start() ; ?top of my html page but eroor is still
"Warning: session_start() [function.sessio n-start]: Cannot send
session cookie - headers already sent by (output started at C:\Program
Files\Apache Software Foundation\Apac he2.2\htdocs\ra jput_new
\loginform.html :2) in "
situ

From the manual at
<http://us2.php.net/manual/en/function.sessio n-start.php>

"If you are using cookie-based sessions, you must call session_start()
before anything is outputted to the browser."

You can output absolutely nothing before the call to session_start - no
DOCTYPE, no tags, not even any white space.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attgl obal.net
=============== ===


I remove all the white space from my file and IT works when First
I hit my page but when I come again to same page after some validation
then it gives me the error....

Warning: session_start() [function.sessio n-start]: Cannot send session
cache limiter - headers already sent (output started at C:\Program
Files\Apache Software Foundation\Apac he2.2\htdocs\ra jput_new\login. php:
4) in C:\Program Files\Apache Software Foundation\Apac he2.2\htdocs
\rajput_new\log inform.html on line 1
Thank you in advance

situ

Jun 21 '07 #5
up********@gmai l.com wrote:
On Jun 21, 4:43 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
>upendra...@gma il.com wrote:
>>On Jun 21, 3:00 pm, Mattia Gentilini
<Mattia.Genti lini_REMOVE_@_R EMOVE_CNAF.INFN .ITwrote:
upendra...@g mail.com ha scritto:"Warnin g: session_start() [function.sessio n-start]: Cannot send
session cache limiter - headers already sent ...."
I don't know how can I handle with this error.
I experienced the same warning when I use the header() function after
output-ing some text e.g.
echo("<html> ");
header("Cont ent-Type: text/html");
Try to check if you have the same situation.
--
|\/|55: Mattia Gentilini e 55 GMG
|/_| ETICS project at CNAF, INFN, Bologna, Italy
|\/|www.getfirefox.comwww.getthunderbird.com
* Using Mac OS X 10.4.10 powered by Cerebros (Core 2 Duo) *
Thank you very much for giving prompt reply .. I tried as you write
but It cann't work and I remove my header.inc and use
<? session_start() ; ?top of my html page but eroor is still
"Warning: session_start() [function.sessio n-start]: Cannot send
session cookie - headers already sent by (output started at C:\Program
Files\Apach e Software Foundation\Apac he2.2\htdocs\ra jput_new
\loginform.ht ml:2) in "
situ
From the manual at
<http://us2.php.net/manual/en/function.sessio n-start.php>

"If you are using cookie-based sessions, you must call session_start()
before anything is outputted to the browser."

You can output absolutely nothing before the call to session_start - no
DOCTYPE, no tags, not even any white space.

--
============== ====
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attg lobal.net
============== ====

I remove all the white space from my file and IT works when First
I hit my page but when I come again to same page after some validation
then it gives me the error....

Warning: session_start() [function.sessio n-start]: Cannot send session
cache limiter - headers already sent (output started at C:\Program
Files\Apache Software Foundation\Apac he2.2\htdocs\ra jput_new\login. php:
4) in C:\Program Files\Apache Software Foundation\Apac he2.2\htdocs
\rajput_new\log inform.html on line 1
Thank you in advance

situ
Well, the obvious answer is somewhere in your validation code you're
outputting something. Possibly white space, error message or something.

You should also have a message indicating where the output was started
(file and line).

But I'm sorry, I can't be of more help. I can't see your code from this
side of your screen.
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Jun 21 '07 #6
are you trying to send the session_start() function again in your
include file?

Jun 21 '07 #7
On Jun 21, 9:35 am, macca <ptmcna...@goog lemail.comwrote :
are you trying to send the session_start() function again in your
include file?
I am pretty new to php but why couldn't you use output
buffering...... ..

ob_start(); at the very beginning of the php code, then at the end of
the php code use ob_end_flush(); ?

Jun 22 '07 #8
Rik
On Fri, 22 Jun 2007 17:17:28 +0200, charlespb69
<ch************ *@gmail.comwrot e:
On Jun 21, 9:35 am, macca <ptmcna...@goog lemail.comwrote :
>are you trying to send the session_start() function again in your
include file?

I am pretty new to php but why couldn't you use output
buffering...... ..

ob_start(); at the very beginning of the php code, then at the end of
the php code use ob_end_flush(); ?
You could, and it would work, it's just bad programming. You hide an error
somewhere that shouldn't be there. Normal procedure is to do all actions
needed first, possibly with session-starting & conditional redirects, then
output. Just because something goes in the <headof an HTML document
doesn't mean you have to include/output that right away.

--
Rik Wasmus
Jun 22 '07 #9
As we have establisted, this error is caused by sending information to
the browser before sending some header information such as a session
start.

if it works on your first visit but not on subsequesnt ones then you
must be sending some information to the browser before your header
info in that conditional statement.

remember:

NO OUTPUT BEFORE HEADERS

no line breaks,
no white space,
nothing.
(and definately no HTML!)

Dont have the session_start() function in your include file if you
call it from the initial script.

You could also check to see if the session is started already by using
the isset() construct.

hope this is of some help.

Jun 23 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3173
by: Phyzlo | last post by:
Hello, I've recently started learning PHP and have a question. I tried running below script which can be found at http://se2.php.net/manual/sv/function.setcookie.php but I keep getting this message on my browser, why? Warning: Cannot add header information - headers already sent by (output started at /var/www/cookietest.php:2) in
6
3401
by: Lochness | last post by:
I'm hoping someone can help me with this. I've seen and tried various solutions I've seen on the net, but nothing works. Of course it works perfectly on localhost, but when I upload it to the server (1and1.com) it gives errors. The user enters a code, the code is verified, a new one is created and it's supposed to send them to the next page. if (CodeExist($cCode) > 0){ $cNewCode = MakeCode(); $ok = InsertRec($cNewCode);
8
2147
by: Jerry | last post by:
Hi All How can I produce an output to the browser and let the script continue to work in the background, producing a later screen output? Example: Trigger a database search so that the user immediately sees a "...searching..." screen while the script actually searches and later on outputs the result.
6
3434
by: John | last post by:
Hi. I am having a few header problems at the moment with a login page. I don't have my headers at the top of the page where I've learned I need to have them. However, I also know I'm supposed to have the session_start(); at the top of the page as well. So when you have two things that need to be the first which do you put first? And if I put one before the other will that cause problems? Below is a copy of the php from my page. It...
4
10420
by: geshan | last post by:
In php5 I am not able to use include funciton and header("location:""" together please help.
4
2486
by: Joseph Geretz | last post by:
We use a Soap Header to pass a token class (m_Token) back and forth with authenticated session information. Given the following implementation for our Logout method, I vastly prefer to simply code m_Token = null in order to destroy the session token when the user logs out. However, I'm finding that setting class instance to null results in no header being sent back to the client, with the result that the client actually remains with an...
2
1489
by: pks83 | last post by:
Hello I am also facing this problem when i amtrying to send additional header information. Warning: Cannot modify header information - headers already sent by (output started at header.php:96) in my.class.php on line 1198 What is happening over here is that i when i am trying to download an attached file i am passing the additional header information which is conflicting with the header info which has already being sent before. ...
4
2556
by: JRough | last post by:
I have this section at the end of a page ------------------- if ($_POST== 'Open in Excel'){ if (empty($data)) { $data = "\n(0) Records Found!\n";} header("Content-type: application/xmsdownload"); header("Content-Disposition: attachment; filename=". $file_name.date("Y:m:d H:i").".xls"); header("Pragma: no-cache");
11
2342
by: ririe | last post by:
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\Inovasi\get_file.php:2) in C:\xampp\htdocs\Inovasi\get_file.php on line 40 Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\Inovasi\get_file.php:2) in C:\xampp\htdocs\Inovasi\get_file.php on line 41 Warning: Cannot modify header information - headers already sent by (output started at...
0
9298
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10072
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9906
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8737
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7286
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6562
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5172
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3829
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.