检索从PHP的.htaccess登录名 [英] Retrieve .htaccess login name from PHP

查看:97
本文介绍了检索从PHP的.htaccess登录名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

的.htaccess 是一个方便的方式来过滤访问一个页面,这要归功于比如基本身份验证。

.htaccess is a convenient way to filter accesses to a page, thanks to the Basic authentication for instance.

在这种情况下,在

  Require user chandler monica ross rachel

将授权访问页上面提到的4人(条件是它们进入其相应的密码)。

will authorize the access to the page to the 4 persons mentioned above (provided that they enter their appropriate password).

是否有可能在PHP检索中输入用户的登录名,她登录后?

Is it possible in PHP to retrieve the login name that was entered by the user, after she logged in?

例如钱德勒的在日志和访问的index.php ,才可能找出的钱德勒的是使用页面从的index.php code?

For instance chandler logs in and accesses index.php, is it possible to find out that chandler is using the page from the index.php code?

推荐答案

根据手动如果您使用的基本验证:

According to manual if you are using basic authentication:

echo ($_SERVER['PHP_AUTH_USER']);

基本身份验证方法现在是pcated德$ P $,我sorongly鼓励使用摘要验证,而不是更困难。相反的htpasswd ,你可以使用 htdigest 二进制。这里也是这样的例子在链接的手册页。

Basic auth method is deprecated now, I sorongly encourage to use digest authentication which is not more difficult. Instead of htpasswd you can use the htdigest binary. There is also an example for that on in the linked manual page.

摘要还使用领域的概念。这是同样的事情 AuthName指令您已经使用,但作为基本身份验证只用它来展示给用户,消化也使用它进行身份验证并保存在密码文件

Digest also uses the concept of realm. This is the same thing as AuthName you are already using but as basic auth only uses it to show to the user, digest also uses it for authentication purposes and saves it in password files.

这篇关于检索从PHP的.htaccess登录名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆