Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Retrieve active user from .htpasswd

Posted on 2013-07-01
3
Medium Priority
?
329 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 44

Accepted Solution

by:
Chris Stanyon earned 2000 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 111

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

715 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