I am looking at how I can run a script or function when a user session ends so that I can delete temporary files that may be required.
I searched around SO to find a solution to this problem and stumbled upon this one , but I find that I am a bit out of depth and I find the PHP documentation regarding what the GC is confusing (and from what I understand from the documentation - this is not exactly what I need).
I looked at the session_set_save_handler page and came up with the following:
session_set_save_handler( '', '', '', '', 'deleteDocs'); function deleteDocs() { rmdir('user/' . rawurlencode($_SESSION['data']['user']['details']['email']) . '/temp'); }
However, this function does not start at all. Honestly, with this, I feel like I donβt know what I'm really doing.
I tried using GC and looked at session.gc_divisor and session.gc_probability , but I still can't edit php.ini.
Can this be achieved. Should I use the cron job - if so, how can I verify that the sessions are finished?
source share