Page 1 of 1
cleanup of server side session files..
Posted: Thu Mar 27, 2003 10:17 am
by scints
i saw one new session file appear each time i use a new IE to open my php which uses session, and those session files remains there even IE close. How to clean them up automatically?
cleaning session files
Posted: Thu Mar 27, 2003 12:33 pm
by musashi
I am assuming you are referring to the session files in the /tmp directory (if you are on a unix system. Not sure where they are on windows).
Anyway, those files are cleaned up by the session_gc (the garbage collection routine). If you didn't modify this routine (by making a customized session handler) then PHP will take care of the clean up for you. If you don't see the files disappear after a while you might want to check your php.ini file to insure that the gc has a short max_lifetime (default is 1440 in seconds). And that the gc_probability is set to something fairly high (default is 1, which is in percentages so 1 = 100%, 0.9 = 90%, etc.)
If you really want to work at it you can delete the files by hand with your own function, or you can customize the session handling and make your own gc function. It all depends on what you are trying to do. If there is sensitive information, you might consider this, or encrypting the session file data (something like mcrypt with the $_SESSION var contents).
