tags:

views:

52

answers:

3

This simple issue I know, in my program session variable is already working properly but now it show some error. I am starting the session in my config page with session_start(); ob_start(); And then include this page in all pages. But if run the program I receive this error message:

Cannot send session cache limiter - headers already sent

If remove the included config page the session variable is notworking.

session_start();
  ob_start();

  $dbcont = mysql_connect("localhost","root","");
  mysql_select_db("emplist",$dbcont);

if($_POST["subSubmit"]=="Submit") {
    $user = $_POST["txtUsername"];
    $pass = $_POST["txtPassword"];


    if ($user == "user" && $pass == "pass") {

     $_SESSION["uaid"] = "ADMIN SECTION";

     header("Location:welcome.php");
       exit();
    }else{
    $err = "Login Failed. Check You UserID/Password";
    }

     }



?>

<html>
    <head>
        <title>.:: Employee Management ::.</title>

</head>
    <body>


              <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="form1" id="form1" onSubmit="return checklogin();">

             USER ID : <input type="text" name="txtUsername" id="txtUsername" onKeyUp="return clearerr();">

             PASSWORD : <input type="password" name="txtPassword" id="txtPassword" onKeyUp="return clearerr();">

             <input type="submit" class="FormButton" name="subSubmit" id="subSubmit" value="Submit">
                                        &nbsp;
             <input type="reset" class="FormButton" name="butReset" id="butReset" value="Reset">

                    </form>

    </body>
</html>

This is my main page code. If login is successful then the control will be moved to "Welcome.php" page in that page I just echo the session variable.

+1  A: 

Try to delete BOM symbols rom script.

Alexander.Plutov
A: 

If you haven't already, try putting session_start() before any output is generated from the script.

jay.lee
No I Just Put session Start in my main pages only,
Meena
+1  A: 

move the session_start(); to the very top

You see, The RULE is you cannot have anything before the session_start(); NOT ONE CHARACTER, otherwise, the browser thinks the webpage has already started, so before you start session_start(); YOU CANNOT START THE HEADER. You start the header with any character, this includes white spaces (space bar).

So also choose your browser Accordingly.

Wazzy
I Edit my post please Check My code is there is any problem in the session variable declaration
Meena
Yes I left 2 line Break Before the Session Start Now i remove That spaces Its working properly .
Meena