• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

cookie vs session

 
Mamadou Touré
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks,

I'm a little bit confused when it comes to using 0 or -1 with setMaxInactiveInterval for the session and setMaxAge for the cookie.

Here is what I mean

1 - What invalidates the session automatically ?
setMaxInactiveInterval(0) or setMaxInactiveInterval(-1)

2 - What makes the cookie disapears automatically when the users exits
setMaxAge(0) or setMaxAge(-1) ?

thanks
 
Phillipe Eduardo Lemos
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mamadou Tour�


The method setMaxInactiveInterval set the time in seconds between the clients requests before sevlet container invalidate the session. The negative values indicate that session will never timeout. If you want to invalidate the session it has two possibilities
a) call invalidate method of HttpSession.
b) set setMaxInactiveInterval to zero.

The method setMaxAge set the maximum age of cookie in seconds. The positive values indicate that the cookie will expire after that many seconds have passed. The negative value means that the cookie
it's not stored persistently and will be deleted when the browser exits. If the value is zero the cookie will delete.
(see http://java.sun.com/j2ee/1.4/docs/api/index.html)

Regards
Phillipe Lemos
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic