getExpiredSessions(); $delCount = 0; if($sessions) foreach($sessions as $session) { if($session->delete()) $delCount++; } echo $delCount . ' session records deleted that were older than ' . self::$session_expiry_days . ' days.'; } /** * Return all MultiFormSession database records that are older than * the days specified in $session_expiry_days * * @return DataObjectSet */ protected function getExpiredSessions() { return DataObject::get( 'MultiFormSession', "DATEDIFF(NOW(), `MultiFormSession`.`Created`) > " . self::$session_expiry_days); } } ?>