Determining when session expires

Advertisement
November 30

I want to be able to track the amount of time that the user spends on my site. I am going to insert a record into a database when the user logs on. I also want to insert a record when the user's session expires either from timing out or closing the browser window or leaving my site. Is it possible to determine when a user's session ends, particularly when it ends via the last two ways.
Thanks!

Advertisement

Replay

First, you can use a javax.servlet.http.HttpSessionBindingListener object put into the session as an attribute and implement the valueUnbound() method to do the database update. This will be called when you invalidate the session (unless you remove the attribute manually first).
So the problem is when will the session be invalidated..... There are really 4 things you are looking for:
1) session times out
2) user logs out (assuming you provide a log out link that invalidates the session)
3) browser closes
4) user leaves site (I assume you mean just goes to some other site in the same browser window)
1 and 2 are okay, cuz it invalidates the session and calls the valueUnbound method of the object you create as mentioned above.
For 3 and 4, you can do this in one of 2 ways:
A) Use frames in your web pages and in the top window, you can have a Javascript call some logout page. However, I'm not convinced that this will work in all situations.
B) Have an applet in the pages that does something to keep the connection alive. This requires an applet and a JVM in the client to run it. Probably not a good thing to rely on for public sites.
So really, there is no foolproof or simple way to handle 3 and 4, except to use session timeouts and rely on that.

View 2 Replies

Tags:

  1. removing exeifes apple id
  2. Nokia 6120c midp certificate download
  3. sattellite l650 1mm system unit psk1 je
  4. difference in fgi0 and ke30
  5. fb02 auth objects
  6. cisco wlc dynamic interface
  7. does STATUS_CHANGE_EXTERN COMMIT WORK
  8. 36K2
  9. surprise6bi
  10. dutys4l
Copyrights 2019 Fcffair BigData Resource, All rights reserved