mepaco Posted November 14, 2007 Share Posted November 14, 2007 Let me preface this with an admission that I am completely new to PHP and if this is not the appropriate place for such beginner questions, I'm sorry. With that out of the way, I'm trying to work on a project that involves adding functionality to a website. They have it segmented so that most pages don't require any authentication but one directory (used for all intranet pages) uses a .htaccess file to authenticate users through an LDAP server. From there, all the pages in that directory look for $_SERVER['REMOTE_USER'] to get the username and populate the page with the proper information. The problem is that I'm not allowed to use their development environment, including the LDAP server. I got their site up and running on my local box (sans LDAP) and thought that maybe I could work around the authentication by deleting the .htaccess file and creating a fake login page that simply asks for a username and populates $_SERVER['REMOTE_USER']. This doesn't work at all. After populating it and redirecting to another page, $_SERVER['REMOTE_USER'] does not appear to be populated. So, I guess my question is can I set $_SERVER variables, does this seem like it should work, or do I have to try and set up an LDAP server? Thanks, Patrick Quote Link to comment Share on other sites More sharing options...
trq Posted November 14, 2007 Share Posted November 14, 2007 The server array is populated by the server, and while you may be able to write to $_SERVER['foo'] it will be overidden with the very next request. Quote Link to comment Share on other sites More sharing options...
mepaco Posted November 14, 2007 Author Share Posted November 14, 2007 Thank you ... though I was hoping I was just messing something up. Outside of starting a session, is there any other storage variable that I can use to pass information between pages (without sending them in POST or GET) to sort of emulate the REMOTE_USER variable? Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted November 14, 2007 Share Posted November 14, 2007 cookies Quote Link to comment Share on other sites More sharing options...
trq Posted November 14, 2007 Share Posted November 14, 2007 Outside of starting a session, is there any other storage variable that I can use to pass information between pages (without sending them in POST or GET) Not really. A session is your best bet. Armed with your fake login page you could even include something like... <?php session_start(); if (isset($_SESSION['REMOTE_USER'])) { $_SERVER['REMOTE_USER'] = $_SESSION['REMOTE_USER']; } ?> at the top of every page and ou should be fine to code as normal. (I'de even use the auto_prepend_file php ini directive while developing) Quote Link to comment Share on other sites More sharing options...
mepaco Posted November 14, 2007 Author Share Posted November 14, 2007 Thank you both. I think this might not be as bad as I thought. Every page in the intranet directory includes a particular php file right at the top that simply sets $login = $_SERVER['REMOTE_USER']. I just did a little experiment and I think that by adding sessions and a line like you describe ($_SERVER['REMOTE_USER'] = $_SESSION['REMOTE_USER']) to the top of this included file, it will solve my problem. I appreciate the quick help. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.