Re: Script execution after window close
| From: | Nibin V M | Date: | Sun, 04 Mar 2012 15:31:03 +0000 |
| Subject: | Re: Script execution after window close | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-316869@lists.php.net to get a copy of this message | ||
in fact....I really need to remove the file ( which will be created for
every access - making a copy from another location ). I can't leave that
file alone for ever in the user disk space! :(
On Sun, Mar 4, 2012 at 9:01 PM, Ashley Sheridan <ash@ashleysheridan.co.uk>wrote:
> **
> On Sun, 2012-03-04 at 20:49 +0530, Nibin V M wrote:
>
> Hello,
>
> I need to run a few commands when a user close the browser tab. That is, I
> have a php page ( index.php ) and it will create a temporary file to track
> some stuffs. That temporary file should be removed, when the user close the
> browser tab. Is there any way to achieve this?
>
> Thank you,
>
>
>
> Not reliably. There are events in Javascript that you can use to trigger
> an Ajax call (such as onbeforeunload and onunload) but these work slightly
> differently from browser to browser and may not allow you to execute
> anything on the browser if the user is navigating away from the site or
> closing the tab/window.
>
> Why can't you use the session for this, and allow the session to expire
> after a certain period of inactivity, which would be better than
> reinventing what sounds like session behaviour.
>
> --
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>
--
Regards....
Nibin.
http://TechsWare.in