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