I periodically remove the tmp out of session files. Apparently, I mismanage sessions because of the huge number of sessions. How do you manage your sessions, not their amount becoming too large? How do you make sure you do not make a new session if one exists?
Command I have used, not sure how they really work:
ob_start ();
session_save_path("/tmp/");
session_start();
ob_end_flush ();
In a properly configured PHP installation, you shouldn’t need to be cleaning your session data by hand. You should read through the pages on sessions in the manual and check out some of the configuration directives. Odds are that you have set gc_maxlifetime to a very high value, and they simply haven’t reached the “expiry” limit to be automatically collected. You should check your applications to be sure that they aren’t setting strange values for the session settings (using
ini_set()) during runtime.PHP has an internal algorithm that runs on
session_start()that decides whether it should do a garbage cleaning run and remove old session files. For performance reasons, I believe the default chance to do a run each time is 1%, so on average a garbage-collection routine will be started once in every 100session_start()calls. If you find this isn’t enough, you can raise the gc_divisor setting to something higher than 1.