I have a custom PHP class that stores a large amount of data (serialized arrays in a text file) for use with the program. I've set up a garbage collection that every time any user runs the program, it parses through the temp director to delete any files older then one hour. After which the file will be recreated by the program for use.
However, what I would really like is to delete the files when the user presses an input button on my form that closes the page. I've tried passing a JSON object with JavaScript/AJAX using POST, but I couldn't get the variable where it needed to be. By that I mean I have a main page that has a form for user input that further populates a page in an iframe based on user input. The iframe is where I needed the JSON object to go. I was attempting to set a Boolean flag to true (i.e. dead=true) and have my garbage collection check for "dead" and then unlink/delete the file.
At this point I'm just looking for any ideas on how to proceed. I have limitations that prevent me from changing basic framework (i.e. can't install or use jQuery or any other JavaScript LIB).
I've seen a lot of similar questions, but none that have a method I can use. Other solutions use a timed garbage collection, which I'm already doing. I was hoping new techniques or solutions have come to light. I'm not looking for code so much as new techniques to handle this.