Page 1 of 1

On browser close delete file

Posted: Thu Jul 08, 2004 1:56 am
by fresh
hey,

trying to work this simple concept out for a while now, just can't locate the php way of telling if the user closed their browser or navigated away, so that when that happens a file that is generated for them at login, will be deleted... is this possible with PHP alone? thanks

Posted: Thu Jul 08, 2004 2:12 am
by markl999
Not with PHP alone, no (unless you use sessions and use the exipry of that to delete the file).
JS can probably do something to detect a browser close and fire off a request to the server.

Posted: Thu Jul 08, 2004 3:56 am
by JayBird
Yeah, you need to use JavaScript and put your site into frames for it to work.

Search this site, i have explained it at least 2 times before.

Mark

Posted: Thu Jul 08, 2004 10:33 am
by PrObLeM
<body onunload="alert('Your closing the window');">

Posted: Thu Jul 08, 2004 10:39 am
by JayBird
PrObLeM wrote:<body onunload="alert('Your closing the window');">
Thant doesn't work...

That will occur everytime you leave the page, even by click a link, that is why you need to use frames!!

Mark