illuz1on Posted September 10, 2007 Share Posted September 10, 2007 Hey, Getting this error from my login.php, anyone know why it might be happening? Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/remember/public_html/admin/login.php:1) in /home/remember/public_html/admin/login.php on line 2 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/remember/public_html/admin/login.php:1) in /home/remember/public_html/admin/login.php on line 2 Welcome to the remember online administration section..Please login... Then displays the fields... Thanks alot, Chris <?php session_start(); include "db.php"; if ($_GET["op"] == "login") { if (!$_POST["username"] || !$_POST["password"]) { die("You need to provide a username and password to access this page. This is a restricted area. Information Logged."); } $q = "SELECT * FROM `remusers` " ."WHERE `username`='".$_POST["username"]."' " ."AND `password`='".$_POST["password"]."' " ."LIMIT 1"; $r = mysql_query($q); if ( $obj = @mysql_fetch_object($r) ) { $_SESSION["valid_id"] = $obj->id; $_SESSION["valid_user"] = $_POST["username"]; $_SESSION["valid_time"] = time(); $username = $_POST["username"]; setcookie("admin",1); Header("Location: admin.php"); } else { die("Sorry, could not log you in. Wrong login information."); } } else { echo "Welcome to the remember online administration section.."; echo "Please login..."; echo "<form action=\"?op=login\" method=\"POST\">"; echo "Username: <input name=\"username\" size=\"15\"><br />"; echo "Password: <input type=\"password\" name=\"password\" size=\"8\"><br />"; echo "<input type=\"submit\" value=\"Login\">"; echo "</form>"; } ?> Quote Link to comment Share on other sites More sharing options...
phat_hip_prog Posted September 10, 2007 Share Posted September 10, 2007 Session auto start is probably on in your php.ini file, it might not be the best but I use: try { if ( !@ ( session_id() ) ) throw new Exception ("oh no!"); } catch (Exception $e) { session_start(); } If anyone has any other suggestions / improvements here i'd also appreciate! Quote Link to comment Share on other sites More sharing options...
Ephialtes Posted September 10, 2007 Share Posted September 10, 2007 Do you think you could post the contents of db.php too? The error looks like you might have called session_start in the db.php too which would cause that error. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.