How to track login attempts using HttpSession in Java?

后端 未结 1 798
南旧
南旧 2021-01-07 06:10

I have a no-framework web application. I need to implement a simple way to check unsuccessful logins, using sessions. If the user attempts to log in 3 times using incorrect

1条回答
  •  -上瘾入骨i
    2021-01-07 06:21

    You can try the below code

    int loginAttempt = (Integer)session.getAttribute("loginCount");
    
    if (loginAttempt > 3 ){
         // Error message/page redirection 
    }else{
         session.setAttribute("loginCount",loginAttempt++);
    }
    

    0 讨论(0)
提交回复
热议问题