I would to set it up where if someone sends in a request \"logout\" it will automatically take them to a page saying \"successful log out\". If the customer tries to press t
I've found a way around it.
I have 2 files: index.php and logout.php
Here is my 'index.php' code:
# CHECK LOGIN.
if (!isset($_SESSION["loged"])) {
$_SESSION["loged"] = false;
} else {
if (isset( $_SERVER['PHP_AUTH_USER'] ) && isset($_SERVER['PHP_AUTH_PW'])) {
if (($_SERVER['PHP_AUTH_USER'] == L_USER) && (md5($_SERVER['PHP_AUTH_PW']) == L_PASS)) {
$_SESSION["loged"] = true;
}
}
}
if ($_SESSION["loged"] === false) {
header('WWW-Authenticate: Basic realm="Need authorization"');
header('HTTP/1.0 401 Unauthorized');
die('
Need authorization
');
}
And here is my 'logout.php' code:
session_start();
$_SESSION["loged"] = false; // We can't use unset($_SESSION) when using HTTP_AUTH.
session_destroy();