I am developing a web user interface that displays some data from a database and displays it to the user. There are literally millions of different graphs that can be generated, so my idea is to dynamically generate the graph, save it to a temporary file, serve the web page, and finally delete the image after a certain period of time.
Thus, I would like to save the paths to already generated images in $ _SESSION so that the files can be deleted when the session is destroyed. Is there a way in PHP to execute a given function (which in this case will be responsible for deleting the above files) when the session is destroyed, when it happens?
source share