Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Session re-visited

 
Malhar Barai
Author
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
How do I keep the session alive even after the browser window is closed...do I state some time or there some other way too ??
hope I am clear.
TIA
MB
 
Ken Robinson
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Usually, in a vendor specific way, you can configure how long the timeout of a Session is. The server has no idea the browser has closed, so the timeout is usually used to force the 'dead' Session to die after a period of inactivity.
If this is what you are looking for, you will have to search the vendors docs to see how to set this in the server you are using.
 
Malhar Barai
Author
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
What we usually find is whenever the browser is re-launched, we find a new session id...is there any way in which we can retain the same session id ??
And in that way, can we retain the info stored in session ??
Maybe this is what I am looking for.
TIA
MB
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
create a Hashtable in application sope.
put the session there.. send a cookie valid for 2 days for ex.
close the browser.
reopen the browser. read the cookie there. Look up within the HashTable in the appln scope. get that session...
 
Ben Dover
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by R�stem e Zal:
create a Hashtable in application sope.
put the session there.. send a cookie valid for 2 days for ex.
close the browser.
reopen the browser. read the cookie there. Look up within the HashTable in the appln scope. get that session...

Hi R�stem,
out of curiosity, does this object in application scope persist if container restarts or server crashes?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
create a Hashtable in application sope.
put the session there.. send a cookie valid for 2 days for ex.
close the browser.
reopen the browser. read the cookie there. Look up within the HashTable in the appln scope. get that session...

Not a good idea - a session object should be managed by the servlet container only. When you looked after the session expired you would find that it had been invalidated and all the managed links were probably garbage.
However you could make your own custom object to hold whatever needs to be held and save that. If you make it serializable you could write it to disk and recover it later.
Louis - you would have to make specific code provision to persist the object.
Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic