Page 1 of 1

need help with session_start()

Posted: Sat Jul 10, 2004 11:51 am
by mikewooten
i'm getting an error message, can anyone help me with how to fix this so that the error won't show up?
thanks

the error that i'm getting is:
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home2/mwooten1/public_html/wootenmusic8/register_new.php:10) in /home2/mwooten1/public_html/wootenmusic8/register_new.php on line 147

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home2/mwooten1/public_html/wootenmusic8/register_new.php:10) in /home2/mwooten1/public_html/wootenmusic8/register_new.php on line 147
if you want to see the code for this page that is getting the error, please let me know.
i'm not sure why i'm getting this message, can someone help me?
thanks

Posted: Sat Jul 10, 2004 11:59 am
by kettle_drum
You have already sent data to the user before you call the function. If your not physically printing anything that you can see, check to make sure theres no whitespace at the top of the page.

Posted: Sat Jul 10, 2004 12:00 pm
by kettle_drum
Oh in case you didnt know, you must send all headers/cookies to the user before ANY text.

Posted: Sat Jul 10, 2004 12:05 pm
by tim
kettle is not fully corret

you can use output buffering to avoid headers issues

ob_start() at php.net, search.

and also, if you would search or look in the tutorial section, you wouldnt have even needed to ask due to this issue has been covered 10000000x+ times

:roll:

Posted: Sat Jul 10, 2004 12:36 pm
by kettle_drum
Well techincally i am correct :P As all output buffering does is buffer the output - i.e. doesnt SEND any data to the user until you flush it. :)

Posted: Sat Jul 10, 2004 2:46 pm
by mikewooten
thanks for your help
the ob_start() did work for me
thanks

Posted: Sat Jul 10, 2004 3:54 pm
by tim
lol I just meant it was a way to use header() and what not within a page with html beforehand

sheesh kettle your out to get me today huh? :wink:

Posted: Sun Jul 11, 2004 4:02 am
by kettle_drum
Hehe. Sorry it was a long day :P