I am creating a web application, so far I have implemented login and registration. The user can register and then log in to the web application. Everything is working fine. What I am doing is when the user clicks the button Login, the servlet is called, where I check the credentials are correct, if checked, then Save isLoggedInto HttpSessionand redirect it to Home Page.
LoginServlet.java
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
boolean isValidated = false;
...
if(isValidated){
HttpSession session = request.getSession();
session.setAttribute("isLoggedIn", Boolean.valueOf(true));
...
}else{
}
}
HomeController.java
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
HttpSession session = request.getSession();
Boolean isLoggedIn = (Boolean) session.getAttribute("isLoggedIn");
if(isLoggedIn != null && isLoggedIn){
...
}else{
}
}
Suddenly I had a strange problem. If I disable cookies for localhost with FireBug, I can no longer log in. Regardless of entering the correct username or password every time I get redirected to /login?expired.
, Cookies , , session , Cookies .
Cookies - Spring -MVC, .