Help with session issue!

Hello

I have some scripts and in all the pages the first few lines are like this :

1)<?php
2)session_start();
3)include(“somefiles.php”);
.
.

now its all WORKING good at my local server. But when I uploaded the files to the server, it shows me this warning :

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/b/k/e/bkeasler12115/html/login.php:1) in /home/content/b/k/e/bkeasler12115/html/login.php on line 2

Please guide !

You probably saved the files as utf8 with a byte order mark(BOM). Your code editor probably has an option to save it without the BOM. Or, you can choose a different encoding.

add this to the top of your file and see if ‘Headers sent…’ message prints on the page. It will give you a hint where to look for problem

if(headers_sent($file, $line)){
echo 'Headers have already been sent in file '.$file. ’ on line '.$line;

		return true;
	} else{

session_start();
}

Hi

thanks for your reply.

I got this as a reply :

Headers have already been sent in file /home/content/z/e/e/zeeshan11215/html/login.php on line 1

This is what my file look like:

Line 1 - <?php
Line 2 - if(headers_sent($file, $line)){
Line 3 - echo 'Headers have already been sent in file '.$file. ’ on line '.$line;

Please guide !

I have had that issue and no spaces were visible on line 1, I was given an html template that needed php. I spent quite a bit of time trying to figure it out and finally backspaced over the <?php and then re wrote it. Some how their editor put in some invisible char before the php tag.

That would be the BOM.

so if it is a BOM, how to solve it ?

Hi

I just open DreamWeaver and tried to save the file WITHOUT BOM, and I tested again and the problem is still there.

is it related to this thing :

session.cache_limiter =public

??

Sorry, I don’t have any experience with dreamweaver. But I bet you can google it.

You can test the first few bytes of the file to confirm this is the issue.


var_dump(file_get_contents('the_suspect_file.php', 0, null, 0, 5));

the problem solved !

Dreamweaver seems to me not working for BOM. So what i did is that :

  1. open the file in DreamWeaver,
  2. copy all the code, close the file
  3. open notepage,
  4. paste all the code
  5. save on the original file.

This way BOM is really disabled and its working !

WOW ! Thanks !