need help with session_start()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mikewooten
Forum Contributor
Posts: 169
Joined: Wed Feb 11, 2004 12:13 pm
Location: Duluth, Georgia
Contact:

need help with session_start()

Post 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
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post 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.
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

Oh in case you didnt know, you must send all headers/cookies to the user before ANY text.
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post 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:
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post 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. :)
mikewooten
Forum Contributor
Posts: 169
Joined: Wed Feb 11, 2004 12:13 pm
Location: Duluth, Georgia
Contact:

Post by mikewooten »

thanks for your help
the ob_start() did work for me
thanks
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post 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:
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

Hehe. Sorry it was a long day :P
Post Reply