Solved

Retrieve active user from .htpasswd

Posted on 2013-07-01
3
320 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 42

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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.

743 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

13 Experts available now in Live!

Get 1:1 Help Now