Re: Cleaning up automatically when leaving a page

From: Date: Wed, 01 Jul 2009 12:20:30 +0000
Subject: Re: Cleaning up automatically when leaving a page
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-294789@lists.php.net to get a copy of this message
Mary Anderson wrote:
Hi all, I have a php application for which I have a page which creates temporary junk and puts it into a persistent store (in this case a postgres database, but that is beside the point.) I have a Save button which puts the stuff I really want into the persistent store and cleans up the temporary junk. I have a Cancel button which only cleans up the temporary junk. I would really like to have the cleanup code run anytime a user leaves the page without hitting the Save button. Is there anyway to do this? I.e. have php code called conditionally on exiting the page? Thanks Mary
I assume you looked at register_shutdown_function() and session_set_save_handler() One way I handled this problem is to save the data in "cleanup" files. Then when the page is called by a new client, a function checks the file's time stamp, say if it's more than 10 minutes earlier, does the cleanup process. This technique assumes that a new client will come along and that the cleanup process(es) are fairly fast. Al...

« previous php.general (#294789) next »