On Monday, January 26, 2004, at 02:32  AM, Emmet McGovern wrote:

> Anyone know of a simple way to keep track of the total amount of time a
> user is logged into an application for?

Two ideas.  One is to explore
javax.servlet.http.HttpSessionBindingListener.  
HttpSessionBindingListener is an interface with two functions:
valueBound and valueUnbound.  An implementation can be used to catch
notifications of when a session is created or cleaned up.  I've never
tried this in ColdFusion, and in fact, I'm not even sure it's possible,
but it's worth pursuing.  In the J2EE world, this works great.

My second idea is much easier and will certainly work.  Rather than
trying to measure the time between login and logout (since you never
really know when someone has stopped using your app unless they
explicitly log out, which you cannot count on them to do), measure the
time between login and the users last request.  Store the current time
at login-time (inside your CFLOGIN tag, possibly), then record the time
on every request after that (use the session scope to make the time
user-specific).  The total time logged in will (approximately) be
timeOfLastRequest - loginTime.

Christian
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to