tags:

views:

491

answers:

2

Im trying to set up a session and i am getting a header error, dispite as far as i can tell i am telling it to start the session before the header is sent. any help here would be useful.

<?php
ob_start();
session_start();
$_SESSION['active'] = 1;
ob_end_flush();
?>
<html>
<body>
2009c Christ Redeemer Catholic Church 
</body>
</html>

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/content/k/u/r/kuriomister/html/temp/church/index.php:1) in /home/content/k/u/r/kuriomister/html/temp/church/index.php on line 3

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/k/u/r/kuriomister/html/temp/church/index.php:1) in /home/content/k/u/r/kuriomister/html/temp/church/index.php on line 3

+1  A: 

See the output: Cannot send session cookie - headers already sent by (output started at /home/content/k/u/r/kuriomister/html/temp/church/index.php:1). You seem to have some whitespace (spaces, tabs, linebreaks, ...) at the beginning of the file.

Piskvor
+4  A: 

If you use UTF-8, be sure to save the file without BOM.

Gumbo
thanks, that was the key.
BOM = Byte Order Mark. UTF-8 = Unicode Transformation Format 8-bit encoding
Anthony Faull
I am having this exact same problem all of a sudden, sitewide on every page on my whole server. I havent even changed anything, it just started happening a few hours ago, I can evern create a new test file that uses sessions and it will give the same errors even when there is not spaces before output, any ideas how to fix?
jasondavis