Jump to content

error with sessions


udaystrad

Recommended Posts

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
{
}
?>
 

 

Link to comment
Share on other sites

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....

Link to comment
Share on other sites

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 by udaystrad
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.