session_start ();
?>
$GLOBALS ['user'] = "test";
$GLOBALS ['pass'] = "test";
if (isset ( $_POST ['user'] ) && isset ( $_POST ['pass'] )) {
if (strcmp ( $_POST ['user'], $GLOBALS ['user'] ) == 0. && strcmp ( $_POST ['pass'], $GLOBALS ['pass'] ) == 0) {
$_SESSION ['user'] = $_POST ['user'];
$_SESSION ['pass'] = $_POST ['pass'];
} else {
?>
Sorry, you have entered an incorrect login.
}
}
if ($_POST ['logout'] == "yes") {
unset ( $_SESSION ['user'] );
unset ( $_SESSION ['pass'] );
session_destroy ();
}
function checkcookies() {
if (strcmp ( $_SESSION ['user'], $GLOBALS ['user'] ) == 0. && strcmp ( $_SESSION ['pass'], $GLOBALS ['pass'] ) == 0) {
return true;
} else {
return false;
}
}
?>
if (checkcookies ()) {
?>
you are logged in!
//Or else present a login form.
} else {
?>
}
?>