• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

setMaxInactiveInterval and <session-timeout> question

 
Chrix Wu
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
are the following four the same ?




 
Chrix Wu
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Found a potential incorrect note in FREDERIC ESNAULT's revision notes

he said in setMaxInactiveInterval() , -1 works like invalidate()

but the offical API said A negative time indicates the session should never timeout.

why??
 
swapnl patil
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
setMaxInactiveInterval() takes time in second and web.xml we specify the time in minute.

then think on it. Read Head first for Servlet & JSP Session management chapter for more clarification .
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Session
setMaxInactiveInterval(0) == invalidate()
setMaxInactiveInterval(-1) == session will never expire

Cookie
setMaxAge(0) == cookie is invalidated
setMaxAge(-1) == cookie is valid till browser closing
 
Chrix Wu
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lucas Smith wrote:Session
setMaxInactiveInterval(0) == invalidate()
setMaxInactiveInterval(-1) == session will never expire

Cookie
setMaxAge(0) == cookie is invalidated
setMaxAge(-1) == cookie is valid till browser closing


what if i set the "time-out" in DD to the value of -1?
 
Ankit Garg
Sheriff
Posts: 9521
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the servlet spec about <session-timeout>
If the timeout is 0 or less, the container ensures the default behavior of sessions is never to time out.
 
Chrix Wu
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ankit Garg wrote:From the servlet spec about <session-timeout>
If the timeout is 0 or less, the container ensures the default behavior of sessions is never to time out.

Thanks
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's misleading.
setMaxInactiveInterval(0) -> invalidate()
<session-timeout>0</session-timeout> -> never invalidate
 
warunyou rattanabuangam
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lucas Smith wrote:Session
setMaxInactiveInterval(0) == invalidate()
setMaxInactiveInterval(-1) == session will never expire

Cookie
setMaxAge(0) == cookie is invalidated
setMaxAge(-1) == cookie is valid till browser closing


thank you.
 
Cristian Daniel Ortiz Cuellar
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
warunyou rattanabuangam wrote:
Lucas Smith wrote:Session
setMaxInactiveInterval(0) == invalidate()
setMaxInactiveInterval(-1) == session will never expire

Cookie
setMaxAge(0) == cookie is invalidated
setMaxAge(-1) == cookie is valid till browser closing


thank you.


if i make request.getSession(false).setMaxInactiveInterval(0); the session will never expire..

 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2403
93
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
have a look at this thread for more about his subject.

Regards,
Frits
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic