Page 1 of 1

session_start Error !!

Posted: Sat Nov 15, 2003 4:07 am
by lazersam
Hi all
I am very new to PHP and so have lots of newbie questions :)

I am using the session_start() function at the top of my page and get this error...

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/centurio/public_html/PHP/validate.PHP:1) in /home/centurio/public_html/PHP/validate.PHP on line 1

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/centurio/public_html/PHP/validate.PHP:1) in /home/centurio/public_html/PHP/validate.PHP on line 1

the top line looks like this... <?php session_start();

there is nothing before the statement! I have also tried this...

<?php
session_start();

but get the same error! I have searched the web and can't seem to get an explaination. I get the same result from 2 different servers.

Any ideas? Thanks in advance.

Lawrence.

Posted: Sat Nov 15, 2003 4:50 am
by lazersam
It's OK People - I solved it !!!

All I had to do is remove the 3 blank spaces before the " <? "

Der...

Lawrence.

Posted: Sat Nov 15, 2003 1:28 pm
by McGruff
You got it. As you probably realise by now, you can't have any browser output prior to session_start - whitespace often catches people out.

Also note that session_start doesn't have to be the first thing in the script: can go anywhere before you start echo'ing or any other browser output.