I have seen several HTTP Authentication tutorials online, but I cannot get the code to work correctly.
if (!isset($_SERVER['PHP_AUTH_USER'])) {
header('WWW-Authenticate: Basic realm="Private Area"');
header('HTTP/1.0 401 Unauthorized');
echo 'You are not authenticated to view this page';
exit;
} else {
//Verify user access against the databse and get access levels
}
My problem is that there is no popup box asking for the login and password, the screen just displys the line of text telling me that im not authorised.
This code is in the page initialisation section, and is run before anything is output, so i assume the header() command is going off correctly.
I'm running a fresh installation of the latest version of PHP on IIS.
Is there some config trick I have missed?