• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

php problem.

tinkerbell

n00b
Joined
Jul 20, 2006
Messages
2
Hey. I'm currently designing a site with a membership system. I've run into a problem and I am not quite grasping the error that it is giving me.

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home2/houseofc/public_html/main.php:2) in /home2/houseofc/public_html/sessions.php on line 47

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home2/houseofc/public_html/main.php:2) in /home2/houseofc/public_html/sessions.php on line 47

Code:
function startSession(){
      global $database;
      session_start();   <-line 47

Any help would be greatly appreciated.
 
That means that something before line 47 is sending data to the client. session_start() has to be the first thing that outputs to the client computer, or your will get this warning.

When I was a php programmer, the most common cause of this problem was whitespace before the <?php at the beginning of the file. However, any line that causes output to the client before the session_start() will cause this.
 
Also check for white space after the final ?>
Usually on the page that your trying to load.
 
Thanks both of you for the help. I'm still new to php and I keep forgetting that the mistake isn't always on the line mentioned. Problem fixed now. You guys are awesome!
 
Note that you can use a buffer if you absolutely needed too. But, its much wiser to keep consitant and keep headers and such where their name implys. Glad you got it fixed :)
 
Output buffers are great. I don't think they are an 'if you absolutely need them' affair. They increase performance, allow you to make great alterations if your output down the pipe, and take care of issues like these header problems.

I always use an output buffer and run the html it generates through a whitespace stripper as well to cut down the size of the html files returned to the client. They have got to be one of the handiest features.
 
Back
Top