开发者

Execute function on session destruction

开发者 https://www.devze.com 2023-01-07 11:10 出处:网络
I am developing a web-based user interface that plots some data from a database and displays it to the user. There are, literally, millions of different graphs that may be generated, so my idea is to

I am developing a web-based user interface that plots some data from a database and displays it to the user. There are, literally, millions of different graphs that may be generated, so my idea is to dynamically generate the graph, save it to a temporary file, serve the web page and finally remove the image after a certain period of time.

What I would like to do, thus, is to store the paths to the already generated images in $_SESSION so that the files can be deleted when the session is destroye开发者_如何学Cd. Is there a way in PHP to execute a given function (which in this case would be in charge of deleting the aforementioned files) when the session is destroyed, whenever that happens?


Yes, see session_set_save_handler, in particular the $destroy and $gc parameters.

0

精彩评论

暂无评论...
验证码 换一张
取 消