udaystrad Posted October 25, 2013 Share Posted October 25, 2013 warning session_start(): Cannot send session cookie - headers already sent by (output started at /home/stradsol/public_html/servers.php:1) in /home/stradsol/public_html/servers.php on line 2 warning session_start(): Cannot send session cache limiter - headers already sent by (output started at /home/stradsol/public_html/servers.php:1) in /home/stradsol/public_html/servers.php on line 2 My code <?php session_start(); if((isset($_SESSION['uname']) && isset($_SESSION['pwd'])) || ($_REQUEST['uname']=='ABC' && $_REQUEST['pwd']=='XYZ')) { $_SESSION['uname'] = 'ABC'; $_SESSION['pwd'] = 'XYZ'; header("Location: SOME-FILE.php"); } elseif(isset($_POST['Submit'])){ $uname=trim($_POST["uname"]); $pwd=trim($_POST["pwd"]); if($uname=="" ) { $error= "Error : You did not enter Username."; $code= "1" ; } else{ $error= 'Error : Invalid Entry.'; $code= "4"; } } else { } ?> Quote Link to comment Share on other sites More sharing options...
vinny42 Posted October 25, 2013 Share Posted October 25, 2013 Google your errors before you post, because this is an extremely common error; you are sending HTML output before calling session_start(). usually there is an empty line before the PHP tag. Quote Link to comment Share on other sites More sharing options...
udaystrad Posted October 25, 2013 Author Share Posted October 25, 2013 i did try it, i even tried a blank line before the php tag its not workin Quote Link to comment Share on other sites More sharing options...
udaystrad Posted October 25, 2013 Author Share Posted October 25, 2013 and also this tag is right at the start of the page ....... Quote Link to comment Share on other sites More sharing options...
udaystrad Posted October 25, 2013 Author Share Posted October 25, 2013 and also this tag is right at the start of the page before the html stuff..... Quote Link to comment Share on other sites More sharing options...
vinny42 Posted October 25, 2013 Share Posted October 25, 2013 The error message says that there is something printed before the session_start(), that's just how it is. Is this file included by another script? Do you have xdebug installed so you can trace the execution of the script to see what it is doing? Quote Link to comment Share on other sites More sharing options...
udaystrad Posted October 25, 2013 Author Share Posted October 25, 2013 even though i m a beginner i think to my knowledege i havent done ny script so that somethin gets printed before it. pls help. this is a login page which validates input on the same page itself n when sucesful attempt redirects it. sesion start on this page has been introduced so that an already loged in person does get login page again. no this script is not being included by any other script no exdbug installed.... Quote Link to comment Share on other sites More sharing options...
vinny42 Posted October 25, 2013 Share Posted October 25, 2013 Hm.. Have you looked at the page source in the browser to see if anything is visible before the printed error? Quote Link to comment Share on other sites More sharing options...
udaystrad Posted October 25, 2013 Author Share Posted October 25, 2013 (edited) k i did look at it now.... when i right click and go ahead with view page source-> thers nothin before the printed error but when in chrome i click inspect element -> there i can see zopim codes (one js in head tag and then three div of same in body tag folowed by it) these ar above the printed error Edited October 25, 2013 by udaystrad Quote Link to comment Share on other sites More sharing options...
vinny42 Posted October 25, 2013 Share Posted October 25, 2013 So your script does include something before getting to the script you posted. Do you know if your server is setup to se "auto_prepend" or something like that? You may be able to find out more about what's going on if you use debug_print_backtrace() (http://php.net/manual/en/function.debug-print-backtrace.php) at the top of server.php. That will print out the lines of code that were executed before the debug_print_backtrace() was called. Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted October 25, 2013 Share Posted October 25, 2013 the "inspect element" in the browser is showing the DOM of the page that the browser produced. since the output isn't a complete web page, the browser used a default. that output isn't actually being sent from the server. your file is most likely saved as a utf-8 encoded file with the byte order mark characters (BOM). you need to save your file without the BOM characters. 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.