By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,825 Members | 1,364 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,825 IT Pros & Developers. It's quick & easy.

Check if User Has Authenticated

P: n/a
I've got a web site that has a mix of public and private sections.
When you first come to the site, the final option on the menu is
"Private" which forces an authentication and then gives you an
expanded menu that includes all the private sections of the site.
What I'd like to do is give users the proper menu ("public only" or
"public and private") depending on whether they have authenticated
with the site.

I thought of just checking for $_SERVER["REMOTE_USER"] or
$_SERVER["PHP_AUTH_USER"] but if you are on a public page, those don't
exist whether or not you have authenticated with the private sections.
I was hoping not to have to deal with sessions or cookies but is that
the only option I have? Or is there some value somewhere that will
tell me that a user has authenticated and that is available (to PHP)
even in the public areas?

--
Henry
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Henry Hartley scribbled something along the lines of:
I thought of just checking for $_SERVER["REMOTE_USER"] or
$_SERVER["PHP_AUTH_USER"] but if you are on a public page, those don't
exist whether or not you have authenticated with the private sections.
I was hoping not to have to deal with sessions or cookies but is that
the only option I have? Or is there some value somewhere that will
tell me that a user has authenticated and that is available (to PHP)
even in the public areas?


Sessions.
http://www.php.net/session

--
Alan Plum, WAD/WD, Mushroom Cloud Productions
http://www.mushroom-cloud.com/
Jul 17 '05 #2

P: n/a
"Henry Hartley" <he**********@westat.com> wrote in message
news:2d**************************@posting.google.c om...
I've got a web site that has a mix of public and private sections.
When you first come to the site, the final option on the menu is
"Private" which forces an authentication and then gives you an
expanded menu that includes all the private sections of the site.
What I'd like to do is give users the proper menu ("public only" or
"public and private") depending on whether they have authenticated
with the site.

I thought of just checking for $_SERVER["REMOTE_USER"] or
$_SERVER["PHP_AUTH_USER"] but if you are on a public page, those don't
exist whether or not you have authenticated with the private sections.
I was hoping not to have to deal with sessions or cookies but is that
the only option I have? Or is there some value somewhere that will
tell me that a user has authenticated and that is available (to PHP)
even in the public areas?


You will get $_SERVER["PHP_AUTH_USER"] in your public pages once the user
has entered his username/password. The browser doesn't just send the
authentication info to the page which generated the 401 Unauthorized
response. It sends it for all files at the same directory level and below.
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.