This week's book giveaway is in the Cloud forum.
We're giving away four copies of The Business Blockchain and have William Mougayar on-line!
See this thread for details.
Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Allowing a Session to stay alive when browser closes

 
edwardo deleon
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any way to create a session and have it stay alive on the user side when the user closes and then re-opens the browser? I can do it if I create my own cookie and use cookie.setMaxAge(5*60*60); I understand the cookie in the user's browser will be there for five hours even if the browser is closed and reopened. But I would like to use Session objects. I don't see how to keep a session alive if the user closes his browser. I think I understand the server side of Sessions in that if I use session.setMaxInactiveInterval(5*60*60) I know the server side session object will be alive for 5 hours even with no activity from the user. But if the user closes his browser, tough luck, the server side session object is still there, but the re-opened browser has no cookie so the container will create a new session and I am wasting memory with the old session. Should I just trample off and use cookies?
Thanks for any help.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, once the user closes the browser, that's it. They're disconnected from that session and won't be able to re-connect to it.
 
edwardo deleon
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. Now I have something to do tonight, tomorrow and over the weekend. Cookies here I come!
 
hatim osman
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there...
while in this topic, using the seMaxAge() method, how can I make my cookie live at the client machine forever until physically removed by the client?
in other words, what is the value that should be passed to setMaxAge() method?
Thank you in advance
Hatim
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You just have to set the maxage to a very high value.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bosun Bello:
You just have to set the maxage to a very high value.


Bosun,
The original poster was asking about reconnecting to an existing session after the browser has been closed. A longer session timeout will not help in this case.
 
Arvind Mahendra
Ranch Hand
Posts: 1162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bosun Bello:
You just have to set the maxage to a very high value.


or just use -1 to set it to infinity.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Chunnard Singh:


or just use -1 to set it to infinity.


Again,
This is irrelevant once the browser has been closed.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic