Typically, a bookkeeper is a function which is called one time in every n that your PHP script is run, and it looks around a directory or table deleting items that have not been modified for a fixed time period. function cleancarts () { $dir = opendir("sessions"); while ($file = readdir($dir)) { if (ereg('^\.',$file) == 0) { $when = filemtime("sessions/$file); if (time() - 7200 > $when) { unlink