Using PHP, if I set a custom session folder to store session files, what must I do to make sure that old session files eventually get deleted? Is there a way to have Apache or PHP handle this for me, or do I need to set something up to clean this folder out myself? Any information on this subject is greatly appreciated.
I am currently using session_save_path() to change the session folder if that makes a difference.
As long as you don’t use the
N;option on php’s session.save_path setting, PHP will auto-clean stale sessions according to the session.gc_probability / session.gc_divisor / session.max_lifetime settingsIf you’ve rolled your own session handlers, you’ll be responsible for the cleanup.