Hi,

On Thu, 15 Jul 1999, Augusto Sellhorn wrote:

> So I'm using the setMaxInactiveInterval() method, and it does what I
> want. Now I'd like to tell the Session to be removed when the user
> exits the browser. You can do this with cookies, but how can you do
> it with a Session object ???
>
> If it can't be done, would it be a good idea to have a getCookie()
> method in the Session interface ? We need more control :)
>
It cant be done due to HTTP behavior. There is no request sent to the
server when user closes the browser or just navigates completely out of
your servlet engine.

The cookie is "closed" at the broser level, when browser program ends,
the server has no clue about that.

Even if you get the cookie info from the session that will not help
too much - it does not tell you nothing when user's browser is closed.

Workarounds are available all adding more or less drawbacks:

- Implement an logout servlet and put links within all (or some)
  http pages of your application:
  Whithin its doGet() just set a one (zero?) second
  timeout for the current session, so it will expire almost instantly.

  Drawbacks: added servlet, users must click "logout" links or buttons
  in order to be logged out (hard to convince them to do that, just to
  see nothing happens :-)

- Use a very small timeout (let it be 30 seconds)
  for all sessions and have each page
  including a small image (logo, animation...) or frame that refreshes
  each 15 seconds. This image being provided by an
  "ImageRefreshingServlet"   whose only purpose is to send the
   same image binary to the browser.

  When user leaves the application session will expire very quick.
  (too quick one might say)

  Drawbacks: overload on servlet engine. Possible problems on slow links.
    Possible problems with caches. Dont know what happens with doPosts()
    that last longer than 30  seconds to return
    (do they expire session or not?)


Other ideas?


Bye,

Cezar Totth

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to