On browser close delete file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
fresh
Forum Contributor
Posts: 259
Joined: Mon Jun 14, 2004 10:39 am
Location: Amerika

On browser close delete file

Post 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
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post 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.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post 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
User avatar
PrObLeM
Forum Contributor
Posts: 418
Joined: Sun Mar 07, 2004 2:30 pm
Location: Mesa, AZ
Contact:

Post by PrObLeM »

<body onunload="alert('Your closing the window');">
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post 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
Post Reply