Here is my code for creating the session. This will be called when the user logs in.
HttpSession session = request.getSession(true);
User user = new User();
String error = "Invalid login or password";
if(user.dbInitialise((String)request.getParameter("login"))) {
String password = (String)request.getParameter("password");
if(password.equals(user.getPassword())) {
User sessionUser = (User)session.getAttribute("user");
if(sessionUser == null) {
sessionUser = new User(user);
session.setAttribute("user",sessionUser);
session.setMaxInactiveInterval(3600);
}
}
else{
session.setAttribute("error",error);
}
}
else {
session.setAttribute("error",error);
}
This code works fine. After the user logs in it will redirect them to the login page and display their name but when I move around the site and leave it idle for 5 min the site will time out. I then have to go back to the login page and login again.
So the session is created but from some reason it does not last one hour. I hope I have provided enough information.
Thank you very much
david