I was wondering if it’s possible to use php to create a file with a specific name that would last 30 seconds, and then delete its self. I looked at the tmpfile and tmpnme functions but I must not know how to use them correctly.
I would like to click a button on webpage A, and then have information shown on webpage B for 30 seconds. Once the 30 seconds is up, the information would change or clear out entirely.
Possible?
PHP can easily create a temporary file for you, but it’ll be up to you to actually remove it after the 30 seconds is up. PHP isn’t a scheduler, though it can schedule things for you via
cronorat.Your best bet would be to embed some extra code into the PHP script as it’s built to specify an expiry time, which the generated script can check when it’s first started:
That’ll take care of the script terminating itself. But if the script is never accessed outside of the 30 second window, it wouldn’t clean itself up, so you’d still need an external job to go in and do some periodic housecleaning.