SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    Confirmed Halfwit
    Join Date
    Oct 1999
    Location
    Vancouver, BC, Canada
    Posts
    983
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to access .htaccess authentication values in php script?

    I have an area of a website that is "protected" by an .htaccess file. Users must "log in" before they can access the files in a certain directory.

    Is it possible for a php script to access the username and password they used to log in?

    If so, are they special variables or something?

    Thanks!
    - A simple online WYSIWYG editor for HTML code snippets.
    - Managed Web Hosting - $3.95/month (resellers welcome)
    - Why pay more? $8.95 domains & $9.95 SSL certificates!

  2. #2
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    see here: www.php.net/manual/en/features.http-auth.php

    PHP has to be running as an Apache module for this to work (not CGI). you can get the login info that they entered if PHP handled the authentication. i'm not sure when it's handled by Apache itself via .htaccess. but the 2 varibables are $_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PW']. try those. note: if your PHP is less than 4.1.0 (you should upgrade), use $HTTP_SERVER_VARS instead of $_SERVER.
    - Matt ** Ignore old signature for now... **
    Dr.BB - Highly optimized to be 2-3x faster than the "Big 3."
    "Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR

  3. #3
    Confirmed Halfwit
    Join Date
    Oct 1999
    Location
    Vancouver, BC, Canada
    Posts
    983
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by DR_LaRRY_PEpPeR
    you can get the login info that they entered if PHP handled the authentication. i'm not sure when it's handled by Apache itself via .htaccess.
    Thanks Doc!

    Anyone know the answer to whether I can get the login info if Apache is handling the .htaccess file and not php?

    Thanks!
    - A simple online WYSIWYG editor for HTML code snippets.
    - Managed Web Hosting - $3.95/month (resellers welcome)
    - Why pay more? $8.95 domains & $9.95 SSL certificates!

  4. #4
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    did you try it? did it not work? i meant that i don't know. it seems like it should work. IF it doesn't, it probably can't be done.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •