php中使用base HTTP验证
function http_auth($un, $pw, $realm = "Secured Area") { if(!(isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW']) && $_SERVER['PHP_AUTH_USER'] == $un && $_SERVER['PHP_AUTH_PW'] == $pw)) { header('WWW-Authenticate: Basic realm="$realm"'); header('Status: 401 Unauthorized'); exit(); //??? } }