Re: Capture logoff on browser close [message #169755 is a reply to message #169747] |
Fri, 24 September 2010 18:18 |
Michael Vilain
Messages: 88 Registered: September 2010
Karma:
|
Member |
|
|
In article <4c9cc0df(at)news(dot)x-privat(dot)org>, MikeB <mpbrede(at)gmail(dot)com>
wrote:
> "Álvaro G. Vicario" wrote:
>> El 24/09/2010 14:50, Bill Braun escribió/wrote:
>>> I would like to update a mysql record with a logoff time if the user
>>> fails to affirmatively logoff and only closes the browser. My research
>>> indicates this is fluky, unreliable, difficult, impossible, or all of
>>> the above. Any practices you know of that may improve the chances of
>>> capturing such a log off time?
>
> Do you specifically only need to capture when the user closes the
> browser (and all cascading events that may force-close the browser - ie.
> if the OS crashes, do you need to record a browser close event?) , or do
> you alos need to capture events such as the user losing network
> connectivity or putting the machine in Sleep/hibernate state and then
> perhaps later resuming without opening/closing the browser? :)
>
>>
>> You've done very good research so there's not much I can add to that.
>>
>> If it is such a mission critical piece of info (or there's a manager
>> that's willing to make you waste time on it) you could try a difference
>> approach. Perhaps you can implement a "ping" feature with JavaScript.
>> Write some client-side code that runs at specific internals (perhaps
>> once a minute) an performs an HTTP request to the server. Store these
>> pings in the database. As soon as they stop coming in, you can assume
>> the user closed the browser (or had a network outage or hibernated his
>> computer or your script stopped working). On this line, you can capture
>> the onbeforeunload event (not sure about the exact name) and send a
>> "bye-bye" ping to the server (if you're very lucky, it may even get on
>> time to the server).
>>
>> This method is fluky, unreliable, difficult, impossible or all of the
>> above so it may suit your problem :)
>>
>>
>
>
> Good points.
Since browser-based applications are supposed to be "stateless", the
standard way to deal with this is sessions. Drupal and Wordpress keep a
session record in their databases when you log into the application.
Indeed, anything you access a Drupal database, there's a session
recorded with the remote IP address. How it deals with sessions from
multiple IPs isn't very good. If I login on a browser window, then open
a tab to the site, that tab assumes I'm logged in as well. Same browser
has the cookie with the session key.
Tracking "they've logged out" is via deleting the cookie and session
record. But it has to be initiated by the user clicking a button.
Tracking "they have left the building" is via a time-out on the session
record. Some banks have a 15 minute active session time. If you don't
do something within that time, you have to login again. Drupal's is
something like 12 hours, I think. Same thing with closing the current
browser's window, but still having a running copy of the bowser. I
don't think Windows does this, but Linux and MacOS (and other Unix
variants do).
Tracking "they closed their browser" could be tracked with an expiring
session cookie set to expire at browser quit.
--
DeeDee, don't press that button! DeeDee! NO! Dee...
[I filter all Goggle Groups posts, so any reply may be automatically ignored]
|
|
|