PHP_AUTH_USER only known in certain frames

Posted by Rob on Stack Overflow See other posts from Stack Overflow or by Rob
Published on 2010-04-28T13:48:42Z Indexed on 2010/04/28 13:53 UTC
Read the original article Hit count: 142

Filed under:
|

Getting very confused by PHP_AUTH_USER. Within my web pages I have .htaccess files in every directory, controlling who can (and cant) see certain folders. In order to further customise the pages I was hoping to use PHP_AUTH_USER within the PHP code, i.e. tailor page contents based on the user.

This only seems to work partially. The code snippets below hopefully demonstrate my problems.

The main index.php creates a framed page with a menu structure in the top left hand corners, some irrelvant stuff in top right and then the tailor made contents in bottom frame. In top left the user is correctly shown, but in the bottom frame PHP_AUTH_USER doesnt seem to be set anymore (it returns empty and when printing all $HTTP_SERVER_VARS its not listed).

Script.php is in a different path, but they all have .htaccess files in them and all other contents is displayed correctly. Why does it not know about PHP_AUTH_USER there?

Running version php version 5.2.12 on chrome.

index.php

 <FRAMESET ROWS="35%, *">
 <FRAMESET COLS="25%, *">
 <FRAME SRC="Menu.php">
 <FRAME SRC="Something.php">
 </FRAMESET>
     <FRAME SRC="../OtherPath/Script.php?large=1" name="outputlisting">
   </FRAMESET>
</FRAMESET>

Menu.php

<ul>
<li>Reporting
<ul>
<li>Link1 <a href="../OtherPath/Script.php" target="outputlisting">All</a>, <a href="../OtherPath/Script.php?large=1"  target="outputlisting">Big</a>
</ul>
<?php
echo 'IP Address: ' . $_SERVER['REMOTE_ADDR'] . '<br />';
echo 'User: ' . $_SERVER['PHP_AUTH_USER'];
?>

Script.php

<?php 
echo 'User: ' . $_SERVER['PHP_AUTH_USER'];
?>

© Stack Overflow or respective owner

Related posts about php

Related posts about authentication