如何使用纯 HTTP 身份验证和 PHP 在 Apache 下获取经过身份验证的用户名?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1417/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 21:07:58  来源:igfitidea点击:

How can I get the authenticated user name under Apache using plain HTTP authentication and PHP?

phpapacheauthenticationhttp-authentication

提问by basszero

First, let's get the security considerations out of the way. I'm using simple authentication under Apache for a one-off, internal use only, non-internet connected LAN, PHP web app.

首先,让我们排除安全方面的考虑。我在 Apache 下使用简单的身份验证作为一次性的、仅供内部使用的、非 Internet 连接的 LAN、PHP Web 应用程序。

How can get I the HTTP authenticated user name in PHP?

如何在 PHP 中获取 HTTP 身份验证的用户名?

采纳答案by Teifion

I think that you are after this

我认为你在追求这个

$username = $_SERVER['PHP_AUTH_USER'];
$password = $_SERVER['PHP_AUTH_PW'];