Solved

Retrieve active user from .htpasswd

Posted on 2013-07-01
3
325 Views
Last Modified: 2013-07-01
Hi all,

Currently to secure the access of a website, I use the combination of .htaccess and .htpasswd.
It's very powerful.

Now I want to go further and I need to retrieve the ID, defined in the .htpasswd, the user uses to be authentified.

Is it possible using PHP to get the value of the identifier ?

Thanks in advance.
Richard
0
Comment
Question by:Richard Coffre
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 42

Expert Comment

by:sedgwick
ID: 39289606
try:
$_SERVER['PHP_AUTH_USER']

Open in new window

0
 
LVL 43

Accepted Solution

by:
Chris Stanyon earned 500 total points
ID: 39289609
You should be able to access the info from the $_SERVER array:

<?php echo $_SERVER['REMOTE_USER']; ?>

Open in new window

0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 39289759
To see all the PHP variables and configuration values, run this script, shown here in its entirety.  The SERVER and ENV variables are near the bottom.  Some of this can be omitted by PHP and some of this is request data, and can therefore be an attack vector, but it's usually right most of the time when it is present.
<?php phpinfo();

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question