devxlogo

Password-Protect ASP Pages Using Session Variables

Password-Protect ASP Pages Using Session Variables

The Active Server Pages Session object provides a quick way to password-protect your pages and force users to log in. The trick is to set a Session variable once the user has been authenticated and then check for the value of the variable at the beginning of each ASP page. For example, this script, session.asp, checks the password (“mypassword”) that is passed from the form. If the password is correct, Session(“loginokay”) is set to true.

 
Continue

In subsequent pages, such as showall.asp shown here, check the value of Session(“loginokay”) and either allow the person in or send the person to the login page.

 You are logged in.

devx-admin

Share the Post: