Page 1 of 1

session variable

Posted: Tue Nov 23, 2010 10:32 pm
by jor123
Hi,

Why am I getting error if try to use session_start();

thanks.

Re: session variable

Posted: Tue Nov 23, 2010 10:34 pm
by s992
What's the error message?

Re: session variable

Posted: Wed Nov 24, 2010 12:10 pm
by jor123
Hi,

Thanks. The error is like this
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /users/mlahon1/chap01/useractivepreviewtmp369.php3:6) in
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /users/mlahon1/chap01/useractivepreviewtmp369.php3:6) in

Re: session variable

Posted: Wed Nov 24, 2010 12:40 pm
by s992
session_start() needs to be at the very top of your page, before anything is output to the browser. For example,

Code: Select all

<?php
session_start();
// Put everything else below this comment

Re: session variable

Posted: Wed Nov 24, 2010 3:30 pm
by jor123
Hi,

Thanks.
I put the session_start() at the very beginning. But still getting the error like this
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /users/mlahon1/chap01/useractivepreviewtmp378.php3:6) in /users/mlahon1/chap01/useractivepreviewtmp378.php3 on line 8