title: Cannot retrieve Apache environment variables in PHP
body: <h1>Background</h1>
  
  <p>I have an Apache/2.2.15 (Win32) with PHP/5.3.2 set up, handling authentication.</p>
  
  <pre><code>&lt;Directory /usr/www/myhost/private&gt;
    # core authentication and mod_auth_basic configuration
    # for mod_authn_dbd
    AuthType Basic
    AuthName "My Server"
    AuthBasicProvider dbd
  
    # core authorization configuration
    Require valid-user
  
    # mod_authn_dbd SQL query to authenticate a user
    AuthDBDUserPWQuery "SELECT Password,UserName,Realm,Access FROM authn WHERE user = %s"
  &lt;/Directory&gt;
  </code></pre>
  
  <p>The authentication works fine! No problems.</p>
  
  <p>But regarding to the <a href="http://httpd.apache.org/docs/2.2/mod/mod_authn_dbd.html" rel="nofollow">documentation</a>, any extra field returned back from the AuthDBDUserPWQuery will be put into an <strong>AUTHENTICATION_fieldname</strong> variable in the Environment.</p>
  
  <p>With <code>phpinfo()</code>, I can see these variables with he correct values under "Apache Environment".</p>
  
  <p><strong>AUTHENTICATE_USERNAME<br>
  AUTHENTICATE_REALM<br>
  AUTHENTICATE_ACCESS</strong>  </p>
  
  <h1>Problem</h1>
  
  <p>I can't fetch those environment variables from my php.  </p>
  
  <pre><code>1 &lt;?php
  2   $Access = apache_getenv('AUTHENTICATE_ACCESS',true);
  3   var_dump($Access);
  4 ?&gt;
  </code></pre>
  
  <p>Line 3 prints bool(false) indicating that the variable wasn't found!<br>
  However if I  change to another Apache Environment variable such as 'HTTP_HOST' it works.<br>
  ..and yes, I have tried <code>getenv()</code> also, same result.  </p>
  
  <p>There is also a note that the Apache server needs to be compiled with APR 1.3.0 to work. I used the Apache msi build from httpd.apache.org and it seems to be compiled with APR above version 2. Since I can see them with <code>phpinfo()</code> they must be accessible from PHP.</p>