Nodda4me
02-21-2007, 11:03 AM
I'm making a login system for my website and trying to use sessions. It will be using a database when it's finished.
The login part is good and everything but when I navigate to another section of the website the session is gone and it wants me to login again.
?php
if (!isset($_SESSION['Login'])) {
session_start();
}
if ($_GET['Login'] == "True") {
if ($_POST['Username'] == "User" && $_POST['Password'] == "123") {
$_SESSION['Login']="GOOD";
} else {
$_SESSION['Login']="BAD";
}
}
?>
Login box:
<?php
if ($_SESSION['Login'] != "GOOD") {
//the login form
if ($_SESSION['Login'] == "BAD") {
session_destroy();
echo "Bad Login";
}
} else if ($_SESSION['Login'] == "GOOD") {
echo "Good login!";
}
?>
The login part is good and everything but when I navigate to another section of the website the session is gone and it wants me to login again.
?php
if (!isset($_SESSION['Login'])) {
session_start();
}
if ($_GET['Login'] == "True") {
if ($_POST['Username'] == "User" && $_POST['Password'] == "123") {
$_SESSION['Login']="GOOD";
} else {
$_SESSION['Login']="BAD";
}
}
?>
Login box:
<?php
if ($_SESSION['Login'] != "GOOD") {
//the login form
if ($_SESSION['Login'] == "BAD") {
session_destroy();
echo "Bad Login";
}
} else if ($_SESSION['Login'] == "GOOD") {
echo "Good login!";
}
?>