Page 1 of 1

Very strange bug in session_start()

Posted: Sun Jan 05, 2014 2:49 am
by bagi
Hi everyone, i'm using Denwer server on my local pc. I have a directory
\account\messages\dialog.php
I run code

Code: Select all

session_start();
On each page (via include_once)

But in this file I get error
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at Z:\home\localhost\www\account\messages\dialog.php:1) in Z:\home\localhost\www\sysTop.php on line 3
What's the problem?

sysTop.php file

Code: Select all

<?
include_once("db.php");
session_start();
include_once("pub.php");
$user = $_SESSION['user'];
$username = getUsernameById($user);
?>
First lines from dialog.php

Code: Select all

<?php
include_once("../../sysTop.php");
$dialog = $_REQUEST['id'];
if(isValidId($dialog))
{
	$gdCnt = mysql_query("SELECT COUNT(*) as cnt FROM dialogsUsers WHERE dialogId='$dialog' AND user='$user'") or die(mysql_error());
	$gdCnt = mysql_fetch_assoc($gdCnt);
	if($gdCnt['cnt'] != 1) moveTo404();
}
else moveTo404();

include_once("../../top.php");

Re: Very strange bug in session_start()

Posted: Sun Jan 05, 2014 3:34 am
by requinix
Somewhere in the list of results of searching for "Cannot send session cache limiter - headers already sent" you'd probably find someone asking how there could be "output started" on the first line of a file. Then there would be a reply mentioning either (a) whitespace before the opening <?php or (b) invisible characters, like a byte-order mark (BOM), at the very start of the file - something that may be there if your editor saves the file in UTF-8 format.

Re: Very strange bug in session_start()

Posted: Sun Jan 05, 2014 4:31 am
by bagi
Yes! Thanks! there was 3 bytes of invisible symbols