예제 #1
0
 public static function gc($maxlifetime)
 {
     $changed = false;
     // check if the last update value exists and if not,
     // set it to NOW, so the update process runs this time.
     if (($nextupdate = XML::root()->getAttribute('next')) == "") {
         XML::root()->setAttribute('next', $nextupdate = self::$_NOW);
         $changed = true;
     }
     // proceed with the update only if its really time for it.
     if (self::$_NOW >= (double) $nextupdate) {
         $sess = XML::query('//session');
         foreach ($sess as $s) {
             // if the id has expired delete it.
             if ($s->getAttribute('exp') <= self::$_NOW) {
                 $s->parentNode->removeChild($s);
                 @unlink(SESS . $s->getAttribute('id'));
                 $changed = true;
             }
         }
     }
     if ($changed) {
         XML::save();
     }
 }