Capture User Log Out Time when browser closed without logout

Capture User Log Out Time when browser closed without logout

  

Hi, 

When you close the browser or tab without using the log-out button, still I want to capture its logged out time. 

I have found javascript event on page unload event but it's not working globally, problem with that is whenever you navigate within the application your page will unload and new page will load, it fails to differentiate between close browser and navigation between pages.

Please let me know, how can we implement this?

Thanks in advance


Regards,

Manish Jawla

Hi,

I specially created an account to be able to reply.

You can try to implement a javascript user inactivity timer like the one outlined here:

http://stackoverflow.com/questions/13246378/detecting-user-inactivity-over-a-browser-purely-through-javascript

and take action user log-out and calculate log-out time accordingly.

happy coding !

Bye,

Frank Hunter

intrax-it

Hi Frank,

i appreciate your effort thank you so much but this not what i want. Its not about user inactivity, its about how can you target only browser close button event. I have to only capture that so that i can perform my desired operation on that event. Javascript or jquery must be able to differentiate between browser close and navigation.

Hi Team,

Any update on the above query? how bank website or google email capture logout time when user close the browser accidentally, how can we achieve the same in outsystem?

Regards,

Manish Jawla

Why not just use a piece of JavaScript on the unload event to call a Web Service on the backend and notify that the tab was closed?

J.Ja

Hi James,

I have used that javascript piece of code, but problem with that is, even when you navigate within the application, it call the page unload event, so its difficult to capture whether you are navigating or you have closed the browser because in both the cases, your page will unload.

Regards,

Manish Jawla

Hi Manish.

You cannot reliably detect if the browser was closed. Consider the case of a hard power off, or battery completely drained. Moreover, the web is made in a way that you cannot know for sure whether a user left by closing a browser, or by navigating away from your web site.


The closest you can get is to have a page unload handler, calling a synchronous ajax request to your server. The ajax request must be synchronous because otherwise there would be a high change of the browser closing your connection. Then you could correlate that with some session information, e.g. storing the timestamp of the last request made by the user. This way you could distinguish between the unload events that are just navigations inside your web app, or navigations on which the user left.

You might also take a look into the Beacon API (still not supported by all browsers) which is meant to handle use cases which require ajax requests in unload handlers.

Thanks Leanardo :), at least I got something but how banking website and gmail, yahoo tracks last logout of the user in such cases, I might be thinking that :) still thanks :)

Regards,
manish jawla


Hi Manish.

From what I can tell, that banks have a very short session, so they know when you "log out" when your session ends.

Gmail probably bases that information on the time of your last request. You could also do that in OutSystems, log each request from a user, and if the user's last request happened, say, more than 10 minutes ago, consider that the user left.

This by no means guarantees that the user logged out or left your site. It could be that the user left your site open without doing anything for 10 minutes.

You can improve on that solution by setting up a javascript interval to make a "heart-beat" request every 5 minutes, so that your server knows that the user is just idle, but hasn't left. But even this solution would fail if the user lost conectivity.