Forums
This topic is locked
Can you retrieve a .htaccess username in PHP
Posted 28 Jan 2002 23:29:12
1
has voted
28 Jan 2002 23:29:12 Stephen Bateman posted:
Does anyone now if it is possible to get the username site visitors have used to get into the site via a .htaccess file. Thanks
GT
Replies
Replied 30 Jan 2002 21:18:25
30 Jan 2002 21:18:25 Tim Green replied:
Not really.... the problem is that the .htaccess file is essentially a flat file. It holds the names of everyone that's authorised to enter that particular area of the site.
You can certainly retrieve all of that information, but it won't be specifically what you need.
The only way to retrieve the kind of information that you're looking for, is by querying the Apache log files (if indeed you are running Apache).
Tim Green
Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
You can certainly retrieve all of that information, but it won't be specifically what you need.
The only way to retrieve the kind of information that you're looking for, is by querying the Apache log files (if indeed you are running Apache).
Tim Green
Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
Replied 14 May 2007 12:20:50
14 May 2007 12:20:50 Dem Pilafian replied:
This thread is <i>ancient</i> old. However, Google seems to like it, so it's worth updating.
The question was not how to read usernames from the <b>.htaccess</b> file -- the question was how to get the username of someone who just logged in using an <b>.htaccess</b> account.
PHP Code:<pre id=code><font face=courier size=2 id=code>$auth_username = $_SERVER["REMOTE_USER"];</font id=code></pre id=code>
Note that different systems might be configured differently, so you may need to dig around a little. Use the <b>phpinfo()</b> function in a password protected file and then view the page (which will require logging in) and search the page for your username.
Edited by - pilaftank on 14 May 2007 12:41:11
The question was not how to read usernames from the <b>.htaccess</b> file -- the question was how to get the username of someone who just logged in using an <b>.htaccess</b> account.
PHP Code:<pre id=code><font face=courier size=2 id=code>$auth_username = $_SERVER["REMOTE_USER"];</font id=code></pre id=code>
Note that different systems might be configured differently, so you may need to dig around a little. Use the <b>phpinfo()</b> function in a password protected file and then view the page (which will require logging in) and search the page for your username.
Edited by - pilaftank on 14 May 2007 12:41:11
Replied 19 Feb 2010 05:50:18
19 Feb 2010 05:50:18 Jose Nunez replied:
@Pilafian, Thanks very much for your response. Even though the post is old, your answer makes it worth.
Replied 24 Apr 2012 15:13:33
24 Apr 2012 15:13:33 Abu Shoeb replied:
Thanks. It Works