doubeng9407 2011-03-08 10:14
浏览 37
已采纳

从PHP中检索.htaccess登录名

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

In this case the

  Require user chandler monica ross rachel

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

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

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?

  • 写回答

3条回答 默认 最新

  • dongxian8272 2011-03-08 10:18
    关注

    According to manual if you are using basic authentication:

    echo ($_SERVER['PHP_AUTH_USER']);
    

    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.

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图