Check if User Has Authenticated

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Henry Hartley

    Check if User Has Authenticated

    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_USE R"] or
    $_SERVER["PHP_AUTH_U SER"] 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
  • Ashmodai

    #2
    Re: Check if User Has Authenticated

    Henry Hartley scribbled something along the lines of:[color=blue]
    > I thought of just checking for $_SERVER["REMOTE_USE R"] or
    > $_SERVER["PHP_AUTH_U SER"] 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?[/color]

    Sessions.


    --
    Alan Plum, WAD/WD, Mushroom Cloud Productions

    Comment

    • Chung Leong

      #3
      Re: Check if User Has Authenticated

      "Henry Hartley" <henryhartley@w estat.com> wrote in message
      news:2d40faa8.0 404140723.4541a e9e@posting.goo gle.com...[color=blue]
      > 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_USE R"] or
      > $_SERVER["PHP_AUTH_U SER"] 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?[/color]

      You will get $_SERVER["PHP_AUTH_U SER"] 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.


      Comment

      Working...