session variable

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
jor123
Forum Newbie
Posts: 3
Joined: Tue Nov 23, 2010 6:37 pm

session variable

Post by jor123 »

Hi,

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

thanks.
s992
Forum Contributor
Posts: 124
Joined: Wed Oct 27, 2010 3:06 pm

Re: session variable

Post by s992 »

What's the error message?
jor123
Forum Newbie
Posts: 3
Joined: Tue Nov 23, 2010 6:37 pm

Re: session variable

Post 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
s992
Forum Contributor
Posts: 124
Joined: Wed Oct 27, 2010 3:06 pm

Re: session variable

Post 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
jor123
Forum Newbie
Posts: 3
Joined: Tue Nov 23, 2010 6:37 pm

Re: session variable

Post 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
Post Reply