I have this login form set out that converts the $_POST data into $_SESSION data. I then use this data to determine whether or not the user should be logged in, however it isn't working. What am I doing wrong?
*** I checked my browser's cookies, and it has the session token stored (if that helps)
login.php:
<?php session_start(); ?>
<form action="page.php" method="post">
Username: <input type="text" name="username" value="" /><br />
Password: <input type="password" name="password" value="" /><br />
<br />
<input type="submit" name="submit" value="Submit" />
<?php
if (isset($_POST['submit'])) {
$username = $_POST['username'];
$password = $_POST['password'];
$submit = $_POST['submit'];
$_SESSION['username'] = $username;
$_SESSION['password'] = $password;
$_SESSION['submit'] = $submit;
}
?>
</form>
page.php:
<?php session_start(); ?>
<?php
$username = isset($_SESSION["username"]) ? $_SESSION["username"] : "";
$password = isset($_SESSION["password"]) ? $_SESSION["password"] : "";
$submit = isset($_SESSION["submit"]) ? $_SESSION["submit"] : "";
if(($username == "username") && ($password == "password") && ($submit == "Submit")) {
echo "You are logged in";
} else {
echo "Denied access";
}
?>
I get this error on pages that include session_start();
According to this post, it is a bug caused by Chrome that is a misleading error report, and doesn't affect anything.