Does anyone know of a simple login script (ASP or ASP.NET) I can implement on a site for the company I work for, please?
What they want to do is place a training site for staff, within a folder off their current site. Ie, www.website.co.uk/training
The training site won’t be linked from anywhere, but they’d like a login box with a generic login (which all staff will know), so they can access the site from home. However, they want the login so noone else will be able to access it if they somehow stumble across it.
Simple stuff… hardcode the login and password (quick and easy) and set a Session variable when someone successfully logs in. Set it to “1” or something.
Basically, put a bit of code at the top of each of the staff-only pages which checks that the session variable is set to “1”. If so, display the page. If not, redirect to the home page (or the login page).
The session variable will expire by itself after 20 mins (by default) of no activity.
eg. at the top of every staff-only page have this:
If Session("LoggedIn") <> "1" Then Response.Redirect "/"
After submitting the login form, the login script simply does this:
If Request.Form("login") = "theloginname" And Request.Form("password") = "thepassword" Then
Session("LoggedIn") = "1"
Response.Redirect "/staff/default.asp" ' or whatever the staff-only home page is.
End If
Response.Write "Incorrect Login" ' and display the login form again.
The above is very messy and not meant to be complete code, just a conceptual example.