Solved

Retrieve active user from .htpasswd

Posted on 2013-07-01
3
322 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
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 108

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
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 …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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.

896 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now