I have a php page in which I have the following code to validate the user using HTTP authentication, this code works fine for http://
url's but when I use the same page with https://
then it didn't ask for username and password.
//authentication settings
define('USERNAME', 'prashant');
define('PASSWORD', 'password');
//Validating
if (!isset($_SERVER['PHP_AUTH_USER'])) {
header('WWW-Authenticate: Basic realm="Authentication required"');
header('HTTP/1.0 401 Unauthorized');
echo 'Unauthorized access';
exit;
}else{
if($_SERVER['PHP_AUTH_USER'] != USERNAME && $_SERVER['PHP_AUTH_PW'] != PASSWORD){
header('WWW-Authenticate: Basic realm="Authentication required"');
header('HTTP/1.0 401 Unauthorized');
echo 'Unauthorized access';
exit;
}
}
What's the problem and how I can resolve this?
Thanks