Jump to content

.htaccess and .htpasswd


Anders Moen

Recommended Posts

I wanna create a page that's only for members with .htaccess, and I've had a code (from DynamicDrive), but I didn't get it work.Can anyone help me with this? And if a user is logged in, I want it to say "Logged in as username", but how do I make it remember the username like that?I appreciate your help :)

Link to comment
Share on other sites

For the logged in as username. It doesn't remember it. It gets the username value in the session variables define when the user logs in.Logged in as <?php $_SESSION['username']; ?>I'm not sure about .htaccess never used it.

Link to comment
Share on other sites

In order to authenticate with .htaccess, your server must be set to support .htaccess as well as the modules required for this. Read How to on authentication for details.As for how to display the name of the one logged in, you need to enable SSIs and/or CGI if they are not already enabled. Then, create an *.shtml file and in it, type:

Logged in as <!--#echo var="REMOTE_USER" encoding="none"-->

Then simply protect that *.shtml file. When the user is logged in, (s)he will see the message.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...