Home » Web Development » 08 - Web Application Development Using ASP
8

User Login - Part 2

The basics of developing the user login system using ASP

The final section is executed if the login is valid. The "login" session variable is set to the user's login ID. Also, the comma separated list of the user's favorite flowers is retrieved from the record set, and split into an array. The first member of this array (favflower(0)) contains a flower that the user likes. The session timeout is set to 30 minutes. This means that the session for a client computer and all the session variables related to it will be reset if no requests are received from the client for thirty minutes. We once again print html output that simply sets a cookie and displays a welcome alert message before loading the home page. To complete login functionality, we will have to add the following Javascript right after the <SCRIPT LANGUAGE="Javascript"> tag in login.htm. The Javascript displays an invalid login alert safter checking to see if the querystring "login" variable that was set. The querystring is set to empty right after the alert is displayed.

var queryString = window.location.search.substring(1);
 if (queryString.length > 0)
   {
    alert("INVALID LOGIN OR PASSWORD! TRY AGAIN");
    window.location.search = "";
   }
Screenshot 8c: Login Page with Updated Navigation

Screenshot 8c: Login Page with Updated Navigation