ASP
  Home arrow ASP arrow Page 5 - Hey... I Remember You!
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Actuate Whitepapers 
Moblin 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP

Hey... I Remember You!
By: Mitchell Harper
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 3
    2001-11-15

    Table of Contents:
  • Hey... I Remember You!
  • Storing the users login details
  • Adding new users
  • Creating the login page
  • The CheckLogin routine
  • The "remember me" part
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
    Iron Speed
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Hey... I Remember You! - The CheckLogin routine


    (Page 5 of 7 )

    The CheckLogin routine is the core of our ASP application and will handle the validation of the user credentials as well as the code that will help our ASP scripts remember the current user.

    Starting on line 45, we are getting the values of the username and password that the user has submitted via the form. On line 46, the strRemember variable will be set to “ON” if the “Remember Me” checkbox was checked on the login form.

    Lines 52 to 54 open a connection to our database server and declare a new recordset object. The LockType and CursorType of the recordset object are set to adLockReadOnly and adUseForwardOnly respectively. These are imported in line 1 via the use of a meta tag. This special meta tag extracts all of the variables from the MSADO15.dll file and lets our ASP script use them as if we had manually declared them ourselves.

    Because we have set both LockType and CursorType values for our recordset, it will only be able to fetch records in a forward seeking motion. This greatly reduces the time it takes to fetch records from the database, because SQL doesn't have to create any locks or temporary data for modified or new records.

    Line 55 executes a SELECT command to get a count of the number of users whose credentials match those passed from our login form and stores the result in our recordset object.

    On line 56, we check how many users the SQL COUNT() function returned. Because we used a “select count(*)” query, our recordset will contain just one row with one field containing the number of users that matched the credentials we supplied.

    On line 57, if at least one user was found matching the credentials from the login form, we check whether or not they have chosen to be remembered. If they have, (strRememberUser = “ON”) then we set two cookie values containing the username and password values (u and p). If they haven't, we wont set the cookie values, but we will set their expiry date to yesterday, which will remove them from the users machine if they existed previously. Alternatively, lines 60 and 61 set the expiry date of our username and password cookies to 30 days from now if the user has chosen to be remembered.

    Lastly, if the login was successful, our script will write one line to the browser: “Hello John. You have logged in successfully”. On the other hand, if the login fails, our ASP script will tell the user that their credentials weren't found in the database.

    More ASP Articles
    More By Mitchell Harper


     

    ASP ARTICLES

    - Central Scoreboard with Flash and ASP
    - Calorie Counter Using WAP and ASP
    - Creating PGP-Encrypted E-Mails Using ASP
    - Be My Guest in ASP
    - Session Replacement in ASP
    - Securing ASP Data Access Credentials Using t...
    - The Not So Ordinary Address Book
    - Adding and Displaying Data Easily via ASP an...
    - Sending Email From a Form in ASP
    - Adding Member Services in ASP
    - Removing Unconfirmed Members
    - Trapping HTTP 500.100 - Internal Server Error
    - So Many Rows, So Little Time! - Case Study
    - XDO: An XML Engine Class for Classic ASP
    - Credit Card Fraud Prevention Using ASP and C...







    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway