<% response.expires = 0 ' When we log in we will set some cookies that can be used by ' ASP files within this application. These cookies will disappear ' when the browser is exited. ' We want to store the following cookies: ' Rights = 0 | -1 | 1 ' User[name] = user login name ' User[Pass] = user password ' User[FullName] = Full user name, from datafile If request("Request_method")="POST" Then ' If this page was called via a POST it means that the ASP page called ' itself posting a user name and user password. We will get the name ' and password and pass it on to the VDF login BPO to check if it is valid. ' get posted information UserName = request.Form("User__Name") UserPass = request.Form("User__Pass") If UserPass<>"" and UserName<>"" then ' call VDF Login_User function. Return non-zero of login ' is ok. LoginOk = oLoginUsers.call("Get_Login_User",UserName,UserPass) else LoginOk = 0 end if ' if login is ok, set browser login cookies. ' if login is not ok, clear cookies. ' Note valuefor Rights = 0 - not logged in yet ' 1 - login successful ' -1 - attempted login failed If LoginOk <> 0 then response.cookies("User")("Name")=UserName response.cookies("User")("Pass")=UserPass response.cookies("User").Path="/" ' if login was OK the login BPO's DD file has the ' current user as its current record. response.cookies("User")("FullName")=oLoginUsers.ddValue("Users.Full_Name") response.cookies("User").Path="/" response.cookies("Rights")="1" response.cookies("Rights").Path="/" Rights = "1" else ' login failed, clear cookies. response.cookies("User")("Name")="" response.cookies("User")("Pass")="" response.cookies("User")("FullName")="" response.cookies("User").Path="/" response.cookies("Rights")="-1" response.cookies("Rights").Path="/" Rights = "-1" end if else Rights = "0" end if ' Note that cookies must be sent before the html header is started %> Login to the Accounting System " TYPE="text/css"> <% If Rights = "1" then %> <% ' If Rights is 1, login was ok. Display welcome message %>

Login Successful


Welcome <%=request.cookies("User")("FullName")%>. You are now logged in at <%=now%>.
You have full system rights. <%else%> <% ' If Rights is not 1, we must login. If rights is -1 we have an ' unsuccessful login attempt. If rights is 0 we have a first time login ' attempt. Display appropriate messages for each event. %>

Please login to the system

<% If Rights = "0" then %>
You will need to log into the system if you wish to add, edit or delete information. You do not need to log into the system if you wish to view data. This capability is extended to all of our guests
<% else %>
Invalid User Name or Password. Please try again
Remember that even without logging in, you still have guest privleges and that you may still view data.
<%end if%>
Enter User Name: (hint: Try "john")
Enter Password: (hint: Try "john")
<%end if%>