Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to use different session timeouts for different levels of users

 
Justin Howard
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

How can I increase the session time out for only admins?

Also I have seen "Keep me logged in forever" in some applications.
How can I do that.

Thanks
 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your web.xml, you can use this piece to declare the default session timeout (in minutes)



a value of 0 causes the session to never expire.

If you want to override this setting, you can programmatically do that on the HttpSession object.



Note that the value you pass setMaxInactiveInterval is in seconds. And a value of 0 will cause the session to immediately expire.
If you want the session to never expire, use -1.

Also, this thread is about the Servlet Spec, hence it belongs to the Servlet forum.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic