getExpiredSessions(); $delCount = 0; if ($sessions) { foreach ($sessions as $session) { $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 DataList */ protected function getExpiredSessions() { return DataObject::get( MultiFormSession::class, "DATEDIFF(NOW(), \"MultiFormSession\".\"Created\") > " . self::$session_expiry_days ); } }