session counter

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Jul 2007
Posts: 276
Reputation: rapture has a spectacular aura about rapture has a spectacular aura about 
Solved Threads: 37
rapture rapture is offline Offline
Posting Whiz in Training

session counter

 
0
  #1
Oct 18th, 2009
I'm fairly new to asp.net and trying to use a session counter to check for when someone has tried to log in three times it counts and when reaches three it locks them out. I know it's easy but my brain is fried.

  1. Protected Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogin.Click
  2.  
  3. Dim IsFound As Boolean = False
  4.  
  5.  
  6. If Page.IsPostBack Then
  7.  
  8. IsFound = clsDataLayer.GetUser(Server.MapPath("AddressBook.mdb"), txtUSERID.Text, txtPassword.Text)
  9.  
  10. If (IsFound) Then
  11.  
  12. 'user credentials were found in the database so notify the system that the user is authenticated
  13.  
  14. lblStatus.Text = "Welcome"
  15.  
  16. 'if authentic then wait three seconds to display the welcome label then send user to mymobilepage
  17.  
  18. Response.AddHeader("REFRESH", "3;URL=mymobilepage.aspx")
  19.  
  20. Else 'invalid user credentials
  21.  
  22. Dim myAttempts As Integer = Convert.ToInt16(Session("AttemptsCount "))
  23.  
  24. myAttempts = myAttempts + 1
  25.  
  26. Session("AttemptCount") = myAttempts 'update the session variable with the new value
  27.  
  28. lblStatus.Text = "The User ID and/or Password supplied is incorrect. Please try again!"
  29.  
  30. If myAttempts >= 3 Then
  31.  
  32. Dim myDAL As New clsDataLayer
  33.  
  34. myDAL.Lockuser(Server.MapPath("Addressbook.mdb"), txtUSERID.Text, False)
  35.  
  36. lblStatus.Text = "Your account has been locked and will need to be reset by the system administrator!"
  37.  
  38. End If
  39.  
  40. End If
  41.  
  42. End If

Can someone direct me the proper way?
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC