Jump to content

Require User Login


afawcett
 Share

Recommended Posts

I am working on a small site, and wanted to password protect it. My teacher's website:http://psy3.ucsd.edu:16080/~psychmickes/psy168.htmldoes a fairly good job of this. Also, even if I send a direct link:http://psy3.ucsd.edu:16080/~psychmickes/psy168su09syl.pdfit requires you to log in. How do I do this? It might be there, but I couldn't find anything in W3 Schools Tutorials.I know she used iWeb, and there is an option to "make site private." Unfortunately I don't have iWeb.

Link to comment
Share on other sites

I am working on a small site, and wanted to password protect it. My teacher's website:http://psy3.ucsd.edu:16080/~psychmickes/psy168.htmldoes a fairly good job of this. Also, even if I send a direct link:http://psy3.ucsd.edu:16080/~psychmickes/psy168su09syl.pdfit requires you to log in. How do I do this? It might be there, but I couldn't find anything in W3 Schools Tutorials.I know she used iWeb, and there is an option to "make site private." Unfortunately I don't have iWeb.
If your webhost uses apache you can google for .htaccess password protect. I don't know how other server applications do it. Often your webhost will have a "password protect directory" option in their control panel.
Link to comment
Share on other sites

You sure can, and it's not really that difficult. All you do, in vague terms, is have a registration form with a username and password field, and you save the username and a hash of the password to the database. A hash is the result of a complex, one way algorithm that creates a uniform length piece of, effectively gibberish from the password. Only that exact sequence of characters can produce the same hash. So when someone signs in, you create a hash of the password from the login form and check it against that in the database. This way, you don't need to actually store the string of someone's password. You can also use the crypt() php function which will do a similar thing. Then, when the user signs in you start a session and store a session cookie. Each page that has member's only content, you check for the presence and of a valid session cookie and if it is present you can display the relevant page data or, if not, redirect them to a public page.

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
 Share

×
×
  • Create New...