/** * Garbage collection * * @throws Session_Exception */ protected function _gc() { if ($this->_lifetime) { // Expire sessions when their lifetime is up $expires = $this->_lifetime; } else { // Expire sessions after one month $expires = Date::MONTH; } $expired = __('this.:column < :time', array(':column' => $this->_columns['last_active'], ':time' => time() - $expires)); try { $this->_collection->safeRemove(array('$where' => $expired)); } catch (MongoException $e) { throw new Session_Exception('Cannot delete old sessions :err', array(':err' => $e->getMessage())); } catch (Exception $e) { throw new Session_Exception('Cannot delete old sessions :err', array(':err' => $this->_db->lastError())); } }