I'm writing a pretty small Flex 2 app and I would like to
track how long a user spends in the app and write it to a database
(using RemoteObject to a ColdFusion Component) at the end of the
session. Short of getting the user to click 'Log Out' to activate
the event, does anyone have any ideas on how I could do this? I am
not using Flex Data Services, so I'll need to do it without it...
It is very difficult to detect when the 'session' ends if you
do not have server-side connections that will tell you when the
browser session disconnects. On the client side, the user can just
navigate to a new URL on a whim.
the Flash Player for your Flex 2 application that detected such an
activity. It might (if the browser allows it to) be able to invoke
a function in the Flex application to finish things up and save
your information. You can look up ExternalInterface to learn how to
I'm not a CF person, but perhaps there is a way on the CF
side to do this. Your Flex app could immediate invoke a "I'm
starting" CFC which holds onto some sesson info. Then perhaps when
the connection is broken, CF can detect it and write out the data.
You'd have to as a CF person about that.
An alternative would be to invoke your CFC repeatedly, say
every 10 seconds. Then if the user exits, you'll at least have an
idea of how long they were in the Flex app to the nearest 10