Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3226318
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:26:30+00:00 2026-05-17T16:26:30+00:00

I want to create a log in system using htaccess and htpasswd file and

  • 0

I want to create a log in system using htaccess and htpasswd file and PHP for the server-side code, but when the user logs in I want to be able to identify that user, so how can I know what the user typed in as their username using PHP code (I assume I won’t need to know the password if they’ve managed to access the restricted page)?

Many thanks,
Ben

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T16:26:31+00:00Added an answer on May 17, 2026 at 4:26 pm

    You just need the following to get the username that is currently in use for an authenticated session:

    $_SERVER['PHP_AUTH_USER']
    

    rev1

    In light of @Ben’s comment I’ve now found the section in the PHP documentation at HTTP authentication with PHP that explains what’s going on:

    As of PHP 4.3.0, in order to prevent
    someone from writing a script which
    reveals the password for a page that
    was authenticated through a
    traditional external mechanism, the
    PHP_AUTH variables will not be set if
    external authentication is enabled for
    that particular page and safe mode is
    enabled. Regardless, REMOTE_USER can
    be used to identify the
    externally-authenticated user. So, you
    can use _SERVER['REMOTE_USER'].

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a log system not to log exceptions , but user
I want to create log file for my flex application. That is the file
I want to create a series of files under log directory which every file
I am using java.util logging classes to create a rolling file appender. I want
I want to create a table of friends with personal information and log on
I want create wordpress website into which I want create user management... That means
i want create Dynamic Slideshow in Jquery i'm Write this code var ctx =
so currently i'm using pods to create some individual pages for a log, filled
I'm using Netbeans to develop a Java application and I want to create a
So, my data are stored in a file, called log.txt, and I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.