FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Capture logoff on browser close
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Capture logoff on browser close [message #169739] Fri, 24 September 2010 12:50 Go to next message
me is currently offline  me
Messages: 192
Registered: September 2010
Karma: 0
Senior Member
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?

Bill B
Re: Capture logoff on browser close [message #169742 is a reply to message #169739] Fri, 24 September 2010 12:58 Go to previous messageGo to next message
alvaro.NOSPAMTHANX is currently offline  alvaro.NOSPAMTHANX
Messages: 277
Registered: September 2010
Karma: 0
Senior Member
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?

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 :)


--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--
Re: Capture logoff on browser close [message #169747 is a reply to message #169742] Fri, 24 September 2010 15:16 Go to previous messageGo to next message
MikeB is currently offline  MikeB
Messages: 65
Registered: September 2010
Karma: 0
Member
"Á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.
Re: Capture logoff on browser close [message #169750 is a reply to message #169739] Fri, 24 September 2010 15:46 Go to previous messageGo to next message
matt[1] is currently offline  matt[1]
Messages: 40
Registered: September 2010
Karma: 0
Member
On Sep 24, 8:50 am, Bill Braun <m...@privacy.net> 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?
>
> Bill B

This is true, but this is not the right place to ask for support.
There's no persistent connection between PHP and your client's
browser, so there's no way to communicate a browser close event unless
something is generated client-side. Same thing with Alvaro's ping
suggestions. I'd try an AJAX or JavaScript group. They should be
able to give you information that's more likely to be reliable across
a variety of browsers.

For example, how can you tell I closed the browser when my browser is
Lynx? :)
Re: Capture logoff on browser close [message #169755 is a reply to message #169747] Fri, 24 September 2010 18:18 Go to previous messageGo to next message
Michael Vilain is currently offline  Michael Vilain
Messages: 88
Registered: September 2010
Karma: 0
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]
Re: Capture logoff on browser close [message #169758 is a reply to message #169750] Fri, 24 September 2010 21:13 Go to previous messageGo to next message
me is currently offline  me
Messages: 192
Registered: September 2010
Karma: 0
Senior Member
On 9/24/2010 11:46 AM, matt wrote:
> On Sep 24, 8:50 am, Bill Braun<m...@privacy.net> 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?
>>
>> Bill B
>
> This is true, but this is not the right place to ask for support.
> There's no persistent connection between PHP and your client's
> browser, so there's no way to communicate a browser close event unless
> something is generated client-side. Same thing with Alvaro's ping
> suggestions. I'd try an AJAX or JavaScript group. They should be
> able to give you information that's more likely to be reliable across
> a variety of browsers.
>
> For example, how can you tell I closed the browser when my browser is
> Lynx? :)

Thank you, Matt. I'm new to this, and while I realize there is a clean
distinction between PHP and MySQL, I do not always know where one stops
and the other starts in practice. I had assumed that this would have
been associated in some way with the session closing, and was thus in
the ballpark of PHP. Good to know, thanks again.

Bill B
Re: Capture logoff on browser close [message #169759 is a reply to message #169739] Fri, 24 September 2010 22:27 Go to previous messageGo to next message
gordonb.bwdc2 is currently offline  gordonb.bwdc2
Messages: 1
Registered: September 2010
Karma: 0
Junior Member
> I would like to update a mysql record with a logoff time if the user
> fails to affirmatively logoff and only closes the browser.

I'm not so sure that users close the browser more than, say, once
or twice a day, at lunch and when they go home. More likely they
just leave the browser up, cover it partially with other windows,
and when they need it again, possibly hours later, they do one of:

- Click a shortcut
- Type something in the search box
- Click "HOME", then click something on that page.
- Type in a URL

If you really need a logoff time, I suggest using technology that
supports such an indication, such as dialup modems, or the mechanism
used in pay toilets.

> My research
> indicates this is fluky, unreliable, difficult, impossible, or all of
> the above.

Correct.

> Any practices you know of that may improve the chances of
> capturing such a log off time?

Insist that the user insert their hand for access (validating
fingerprints is optional), and don't let them remove it until they
log off. This will be extremely unpopular with users, probably to
the point you won't have any.
Re: Capture logoff on browser close [message #169760 is a reply to message #169758] Fri, 24 September 2010 23:55 Go to previous messageGo to next message
Peter H. Coffin is currently offline  Peter H. Coffin
Messages: 245
Registered: September 2010
Karma: 0
Senior Member
On Fri, 24 Sep 2010 17:13:59 -0400, Bill Braun wrote:
> Thank you, Matt. I'm new to this, and while I realize there is a clean
> distinction between PHP and MySQL, I do not always know where one stops
> and the other starts in practice. I had assumed that this would have
> been associated in some way with the session closing, and was thus in
> the ballpark of PHP. Good to know, thanks again.

There's a fairly simple test for whether something is a PHP problem or a
MySQL problem: If the program execution gets to and beyond the point of
the actual attempt to execute a query, then it's probably NOT a PHP
problem per se. If it hangs, dumps core, spits out a error message that
the program itself did not compose, etc., then it might be a PHP
problem. This does not cover all possible cases, but it's the way to
start.

--
51. If one of my dungeon guards begins expressing concern over the
conditions in the beautiful princess' cell, I will immediately
transfer him to a less people-oriented position.
--Peter Anspach's list of things to do as an Evil Overlord
Re: Capture logoff on browser close [message #169761 is a reply to message #169739] Sat, 25 September 2010 00:16 Go to previous messageGo to next message
rf is currently offline  rf
Messages: 19
Registered: September 2010
Karma: 0
Junior Member
"Bill Braun" <me(at)privacy(dot)net> wrote in message
news:i7i6q5$kn2$1(at)news(dot)eternal-september(dot)org...

> 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.

This is correct.

> Any practices you know of that may improve the chances of capturing such a
> log off time?

No. There is no such concept as "log off" in a stateless protocol sush as
HTTP is.
Re: Capture logoff on browser close [message #169764 is a reply to message #169759] Sat, 25 September 2010 10:26 Go to previous message
me is currently offline  me
Messages: 192
Registered: September 2010
Karma: 0
Senior Member
On 9/24/2010 6:27 PM, Gordon Burditt 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.
>
> I'm not so sure that users close the browser more than, say, once
> or twice a day, at lunch and when they go home. More likely they
> just leave the browser up, cover it partially with other windows,
> and when they need it again, possibly hours later, they do one of:
>
> - Click a shortcut
> - Type something in the search box
> - Click "HOME", then click something on that page.
> - Type in a URL
>
> If you really need a logoff time, I suggest using technology that
> supports such an indication, such as dialup modems, or the mechanism
> used in pay toilets.
>
>> My research
>> indicates this is fluky, unreliable, difficult, impossible, or all of
>> the above.
>
> Correct.
>
>> Any practices you know of that may improve the chances of
>> capturing such a log off time?
>
> Insist that the user insert their hand for access (validating
> fingerprints is optional), and don't let them remove it until they
> log off. This will be extremely unpopular with users, probably to
> the point you won't have any.
>


I like your line of thinking, and I think it may revolutionize the web
experience.

Bill B
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Authentication code creation for google analytics API in PHP
Next Topic: APC + Multi-Site Install of Single Application
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 27 04:42:23 GMT 2024

Total time taken to generate the page: 0.02489 seconds