944,082 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 720
  • ASP.NET RSS
Oct 18th, 2009
0

session counter

Expand Post »
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.

ASP.NET Syntax (Toggle Plain Text)
  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?
Similar Threads
Reputation Points: 155
Solved Threads: 41
Posting Whiz in Training
rapture is offline Offline
294 posts
since Jul 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: session counter
Next Thread in ASP.NET Forum Timeline: Label click event





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC