On Tue, Jun 24, 2014 at 12:43 PM, Stuart Dallas <stuart@xxxxxxxx> wrote: > On 24 June 2014 17:39, Aziz Saleh <azizsaleh@xxxxxxxxx> wrote: > >> >> >> >> On Tue, Jun 24, 2014 at 12:26 PM, Stuart Dallas <stuart@xxxxxxxx> wrote: >> >>> On 24 June 2014 17:16, Aziz Saleh <azizsaleh@xxxxxxxxx> wrote: >>> >>>> On Tue, Jun 24, 2014 at 12:08 PM, hadi <almarzuki2011@xxxxxxxxxxx> >>>> wrote: >>>> >>>> > Hi, >>>> > >>>> > Is there's any way to run script when user close the browser in php ? >>>> > >>>> > Thanks . >>>> > >>>> > >>>> > >>>> Yes: http://www.php.net//manual/en/function.ignore-user-abort.php >>>> >>> >>> That's detecting a client disconnection, not the browser being closed. >>> While closing the browser will also close the connection, it's not the only >>> action that will do so. >>> >>> -Stuart >>> >>> -- >>> Stuart Dallas >>> 3ft9 Ltd >>> http://3ft9.com/ >>> >> >> Stuart: >> >> Here is what I can think of: >> >> 1) User closes the browser. >> 2) Internet is disconnected. >> 3) Computer shuts of. >> 4) Intermittent connection. >> >> I could be missing a few (if so, please let us know which). Either way, >> they all are pretty much connection lost which I am 90% is what the OP was >> thinking of (probably didn't think of a way to do something for the other >> cases). >> > > Your 90% scenario is actually... > > Page completely loaded so the script has ended => User closes browser > > Using ignore_user_abort does not get anywhere close to doing what the OP > wants. Not that we actually know what the OP really wants until he tells > us. I'm yet to hear of a legitimate reason to want some PHP to execute when > a user closes the browser, so chances are there's a better way to achieve > what he actually wants. > > -Stuart > > -- > Stuart Dallas > 3ft9 Ltd > http://3ft9.com/ > Ah I see now what the OP means. I guess my mind always jumps to PHP solutions to the issue, when indeed the issue here was to do with the page onunload event. My bad.