• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sessions

 
david allen
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Just a quick question on sessions. I am working on a site that adds a few different objects to the session. For example, User, Album and a few other values. What I want is for the session to expire only when the browser is closed and not if the user does not use the browser for say 15 min.
I have tried session.setMaxInactiveInterval(-1) but that does not seem to do it.
Anyone know how to do it?
Regards david
 
Andres Gonzalez
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried using session-timeout tag in your web.xml.
If you set it with 0 it means that the session will never expire.
 
Sainudheen Mydeen
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
You can set session-timeout tag (web.xml) to a value to 0 or less
Thanks
Sainudheen
 
david allen
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So if I edit the web.xml file so that the session tag is set to zero does this mean a session will only expire when the server is stopped?
What I am after is having the session expire when the browser is closed? Is this possible?
Regards
David
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sadly the browser does not tell the server when it closes. I don't think you can tell the difference between a)user closed the browser b)user went out for dinner & dancing or c)user is busily surfing other sites.
If you really, really gotta know (really!) you can put an applet in the browser and have it send "I'm still here!" messages to the server or have the server send "Are you still there?" messages to the applet. We're buying a vendor product that does this so it can synchronize telephony events and workflow availability with the browser. We're buying it because it ain't easy to build!
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think that "never expire" is what you want - if the servlet engine serializes sessions to disk, your hard drive will just accumulate sessions.
A "keep alive" pulse with JavaScript or applet sounds right for you - then you can let the servlet engine dispose of sessions normally.
Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic