cannot send session cache limiter headers already sent

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rchiu5hk
Forum Newbie
Posts: 1
Joined: Wed Sep 03, 2008 8:38 pm

cannot send session cache limiter headers already sent

Post by rchiu5hk »

Dear all,

I have the error in this file but I don't know what it is and how to fix??
Could you tell me??

Code: Select all

<?php
require_once("config.inc.php");

//connect database
	$dblink = mysql_connect($dbhost, $dbuser, $dbpw);
	mysql_query("SET NAMES 'utf8'");
	mysql_select_db($dbname, $dblink);
//init. session

	session_start();
	session_register('patentusername');
	session_register('admin');
	session_register('view1');
	session_register('view2');
	session_register('add1');
	session_register('add2');
	session_register('dattachadd');
	session_register('dattachview');
	session_register('exportsql');
?>
Last edited by Benjamin on Mon May 17, 2010 9:27 pm, edited 1 time in total.
Reason: Added [syntax=php] tags.
minorDemocritus
Forum Commoner
Posts: 96
Joined: Thu Apr 01, 2010 7:28 pm
Location: Chicagoland, IL, USA

Re: cannot send session cache limiter headers already sent

Post by minorDemocritus »

Make sure that no characters exist in the file before the opening <?php tag. That's the most common cause. Also, enclose your code with the PHP Code button to make it easier to read.
Bind
Forum Contributor
Posts: 102
Joined: Wed Feb 03, 2010 1:22 am

Re: cannot send session cache limiter headers already sent

Post by Bind »

additionally, make sure absolutely no whitespace (spaces), lines (carriage returns or line feeds), or html output ocurrs prior to the attempt to send session/header data.

If, however, your scripting construct does not make it possible and you simply must send data prior to the attempt to send header/session data, then use PHP Output Buffer Control to prevent the error from occurring.

It should be noted that you should make every attempt to re-structure your code to attempt to send header/session data prior any output if at all possible because that is the leanest way to consruct code, which is the least server-resource intensive.
Post Reply