I don't understand how these variables are getting reset...On the first refresh I'm setting the user & pw to practically nothing, and on top of that I unset them. But if I refresh the page again : "Theeeeyy'ree Baaaack". What's going on here??
<?php
session_start();
session_register('logOut');
function authenticate() {
Header( "WWW-authenticate: basic realm=\"Test Authentication System\", stale=FALSE");
Header( "HTTP/1.0 401 Unauthorized");
echo "You must enter a valid login ID and password to access this resource\n";
exit;
}
if(!isset($PHP_AUTH_USER)) {authenticate();}
if ($logOut==1){
$PHP_AUTH_USER=" ";
$PHP_AUTH_PW=" ";
unset($PHP_AUTH_USER,$PHP_AUTH_PW);
$logOut=0;
}
echo "Hello $PHP_AUTH_USER.<P>";
echo "You entered $PHP_AUTH_PW as your password.<P>";
$logOut=1;
?>