【发布时间】:2016-05-06 11:40:00
【问题描述】:
PHP认证码是:
if (!isset($_SERVER['PHP_AUTH_USER'])) {
header('WWW-Authenticate: Basic realm="My Realm"');
header('HTTP/1.0 401 Unauthorized');
echo 'Text to send if user hits Cancel button';
exit;
} else {
echo "<p>Hello {$_SERVER['PHP_AUTH_USER']}.</p>";
echo "<p>You entered {$_SERVER['PHP_AUTH_PW']} as your password.</p>";
}
问题是消息 Basic realm="My Realm" 未在 Chrome 中显示,但它在 Mozilla Firefox 中符合我们的预期。
【问题讨论】:
标签: php google-chrome authentication