Hi
Even if the answer comes nearly 3 years after your question, it may help some other people trying to do the same.
Like you, I have tried to use $SERVER['REMOTE_USER'], $SERVER['PHP_AUTH_USER'], etc. without success.
But after some googling I got the answer (http://www.phpbuilder.com/lists/php3-list/199909/2128.php) : use the Apache "note" variables. Since we can change them from PHP, and write a "note" variable into the log files, we can do the job 🙂
So, in the Apache configuration file, set the log format (ex. combined for me) :
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
To something like
LogFormat "%h %{login}n %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
Then, in PHP, you just have to do for example :
session_start();
apache_note("login", isset($_SESSION['login']) ? $_SESSION['login'] : '-');
Should be Ok.