Thanks, Christopher... I feel better now knowing that I wasn't just missing something really obvious.. on the other hand, I should have thought of the "stateless" aspect myself.... I'll take the timestamp approach, and see what I can come up with... BD http://www.bustdustr.net http://www.rfbdproductions.com The Entertainment Center Home Of Radio Free BD For A Difference. ----- Original Message ----- From: Christopher Ostmo <[EMAIL PROTECTED]> To: BD <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Monday, July 16, 2001 1:42 PM Subject: Re: [PHP-DB] How to drop a table when user leaves prematurely? > BD pressed the little lettered thingies in this order... > > > Ugh! > > > > I'm sure this is fairly simple, but I have yet to come up with a way to do > > it... > > > > In a nutshell, our application creates, uses and drops a table while the > > user is working on the site. Unfortunately, because of "other > > considerations", we can't use a defined temp table - it has to be created > > as a regular table. We have a routine in the app that will drop the table > > once the user is done with their work, but if they leave for some reason > > before they're done, the table is left hanging out there. This wasn't a > > problem at first, but we're building up quite a collection of useless > > tables right now. > > > > Is there any way to drop the table automagically when the user leaves > > prematurely, either by closing their browser or jumping to another site? I > > tried using register_shutdown_function(), but it didn't seem to have any > > effect... > > > > I think, and I know I may be way off base, is that there are a lot of pages > > involved in this application, and I'm not sure how to tell the app that the > > user is just going from one page to the next or is actually going > > bye-bye... > > > > HTTP is stateless (there is no persistent connection between the server > and browser), so there is no way for you to tell the difference on the > server side whether the user has gone to get coffee, has closed his or > her browser or has been abducted by aliens. You can do two things > that are rather unreliable: > 1) Have a "Log Out" button. This is unreliable because many (most?) > people will simply not use it. > 2) Use a javascript to detect when the user has gone away. This is > unreliable because many people disable javascript or use non-compliant > browsers. > > The only sure way to keep your temp tables at a minimum is to store a > creation date or datetime field in the temp table and destroy the table > when it has reached a reasonable age. I prefer to run perl scripts from > cron to do this and typically choose 48 hours as the time at which I feel > that it is safe to assume that the user has abandoned his or her data. > > Good luck... > > Christopher Ostmo > a.k.a. [EMAIL PROTECTED] > AppIdeas.com > Innovative Application Ideas > Meeting cutting edge dynamic > web site needs since the > dawn of Internet time (1995) > > Business Applications: > http://www.AppIdeas.com/ > > Open Source Applications: > http://open.AppIdeas.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]