• Post Reply Bookmark Topic Watch Topic
  • New Topic

Dynamic Session Lengths?

 
Robert Paris
Ranch Hand
Posts: 585
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to change the length of session timeout dynamically for each user based on some data I make up? For example:
1. Anyone logged in as admin, I give a 30 minute timeout on their session
2. Employee logins get 1 hour session timeout
3. Regular users get 10 minute session timeout
How would I do this?
 
Anthony Smith
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Each time a user logs on you use:
HttpSession session;
session.setMaxInactiveInterval(60 * 30); //Your length
You just have to pull the actual values based on each user.
 
Sat Vus
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Robert,
I suppose if you are using the Server side sessions in which case , you can use the solution as specified by Smith.
If you are using cookies based session - cookie.setMaxAge can be used to manipulate the cookie's (session) Age.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!