How to check if a session is invalid

If you want to know whether it valid based on a request:

request.isRequestedSessionIdValid()

  or

HttpSession sess = request.getSession(false);
if (sess != null) {
   // it's valid
}

If you have stored a reference to the session and need to validate I would

try {
  long sd = session.getCreationTime();
} catch (IllegalStateException ise) {
  // it's invalid
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)