session help

From: Date: Fri, 25 Apr 2003 10:27:15 +0000
Subject: session help
Groups: php.windows 
Request: Send a blank email to php-windows+get-19610@lists.php.net to get a copy of this message
I am having trouble using sessions to tell if a user is logged in or not. I have attached some of the code I am using for it. <?php $conn=mysql_connect($dbServer,$dbUsername,$dbPassword); $dbase=mysql_select_db($db,$conn); $check=mysql_query("SELECT requireaccount FROM calendar_config"); $row=mysql_fetch_row($check); if($action=="logger"||$MyLogin=="true") { session_start(); $errors=0; $usercheck=mysql_query("SELECT * FROM calendar_users WHERE username='$uname'&&password='$pword'"); while($row=mysql_fetch_assoc($usercheck)) { $userid=$row[recno]; $namer=$row[username]; $emailaddy=$row[email]; $priv=$row[priv]; } if($userid=="") { die("<center>You don't have and account, or your username and password don't match.<br><a href='javascript:history.back()'>Go back and try again</a></center>"); } elseif($priv=="N"||$priv=="") { die("<center>User: <b>$namer</b> must be approved by the calendar administrator or have sufficient privileges to add events to the calendar.<br><a href='javascript:history.back()'>Go Back</a></center>"); } else { if($MyLogin!="true") { $_session["MyUserID"]=$userid; $_session["MyLogin"]="true"; } } //then the rest of the code comes after this. When I go to access this, I get the following: Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\calendar\header.php:5) in C:\Program Files\Apache Group\Apache2\htdocs\calendar\add_event.php on line 10 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\Program Files\Apache Group\Apache2\htdocs\calendar\header.php:5) in C:\Program Files\Apache Group\Apache2\htdocs\calendar\add_event.php on line 10 Anyone know why? Matt

« previous php.windows (#19610) next »