This is a forum where members new and old can come to ask questions and get info and opinions. It is not a place to advertise your business or have other forms of advertising, whether it be in your posts or signature.

All links in the forum will not be indexed by Search Engines and any unapproved forms of advertising or spam will be dealt with accordingly, deleted, and that member's account banned.

Forums

Overview » PHP » Can you retrieve a .htaccess username in PHP
Reply

Can you retrieve a .htaccess username in PHP

Stephen Bateman
Member



Since: 24 Jul 2001
Posts: 48
Posted 28 Jan 2002 23:29:12

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

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
Tim Green
Zone Manager



Since: 29 Jan 2001
Posts: 736
Replied 30 Jan 2002 21:18:25
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>
Dem Pilafian
Member



Since: 14 May 2007
Posts: 1
Replied 14 May 2007 12:20:50
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
Jose Nunez
Member



Since: 18 Feb 2010
Posts: 1
Replied 19 Feb 2010 05:50:18
@Pilafian, Thanks very much for your response. Even though the post is old, your answer makes it worth.

Reply to this topic

Message
Reply
Follow us on Facebook Follow us on twitter Subscribe to the RSS feed
Activate your free membership today | Login | Currency