Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cannot send session cache limiter - headers already sent

Status
Not open for further replies.

Burglar

IS-IT--Management
Apr 23, 2001
21
Hello all, been a while...anyway, I am using the ziplib class and am getting the following error on one website where I am using sessions:


[Wed Nov 19 10:57:18 2008] [error] PHP Warning: session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cache limiter - headers already sent (output started at /var/ in /var/ on line 28
[Wed Nov 19 10:57:44 2008] [error] PHP Warning: session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cache limiter - headers already sent (output started at /var/ in /var/ on line 28
[Wed Nov 19 10:58:36 2008] [error] PHP Warning: session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cache limiter - headers already sent (output started at /var/ in /var/ on line 28



On a website where I am using cookies, all works beautifully. Please help...

Burglar
 
Sorry, copied the wrong lines of code...here are the 3 error messages I am receiving:


[Wed Nov 19 10:56:56 2008] [error] PHP Warning: session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cache limiter - headers already sent (output started at /var/ in /var/ on line 28
[Wed Nov 19 10:56:56 2008] [error] PHP Warning: Cannot modify header information - headers already sent by (output started at /var/ in /var/ on line 130
[Wed Nov 19 10:56:56 2008] [error] PHP Warning: Cannot modify header information - headers already sent by (output started at /var/ in /var/ on line 131
 
simply stated you cannot send information that should be contained in the http header (such as cookies) after display data has been sent to the browser. this is an inherent limitation of http.

session_start() causes a cookie to be set that is sent to the browser. i've written a []brief article[/url] on sessions here which explains what happens with sessions.

so the way to avoid this issue is to ensure that you call session_start() BEFORE you send any output at all (even a blank line) to the browser. Keep a sharp eye out for things like this
Code:
<?php
session_start();
?>
note that there is a blank line before the <?php. that is sent to the browser and bang goes your session.
 
Actually after pulling my hair out, one of the support files started the file with simply <? not the explicit
<?php and my server is not configured for short_open_tag. Thanks for the response though...I appreciate it.


Burglar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top