Page 1 of 1

cannot send session cache limiter headers already sent

Posted: Mon May 17, 2010 7:21 pm
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');
?>

Re: cannot send session cache limiter headers already sent

Posted: Mon May 17, 2010 7:31 pm
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.

Re: cannot send session cache limiter headers already sent

Posted: Mon May 17, 2010 8:19 pm
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.