I have create a php page for encrypt with HTTP base authentication, sample code below:
<?php
if( !isset($_SERVER['PHP_AUTH_PW']) || $_SERVER['PHP_AUTH_PW'] != '__PASSWORD__') {
header('WWW-Authenticate: Basic realm="__REALM__"');
header('HTTP/1.0 401 Unauthorized');
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<p>hello world</p>
</body>
</html>
Above code works, but browser will presist authentication cache when every time reload the page, so user cannot input password every time page load, So, How to avoid browser to cache authentication?