I save my sessions in a different directory from the / temp directory. let's say /session . (using session_save_path("session") )
there is also code to end the session after 10 minutes from the moment you create and log out.
but I mentioned that if a user logs in and, for example, closes his computer, my logout and session destroy the code domains that are not running, so the session file will remain in the session directory.
I wanted to know if there is a way to delete session files in /session some time after creation?
I used this code for it
if ($handle = opendir('sessions')) { while (false !== ($file = readdir($handle))) { if (filectime($file)< (time()-600)) { // 600 = 10*60 unlink($file); } } }
but without working, I think that he could not get the creation time of filectime($file)
thanks
php session automation
Alireza
source share