Example #1
0
 /**
  * This function handles garbage collection.
  *
  * @access protected
  */
 protected function _gc()
 {
     $expires = $this->_lifetime ? $this->_lifetime : Date::MONTH;
     // Expire sessions after one month
     // Delete all sessions that have expired
     DB_ORM::delete($this->_table)->where($this->_columns['last_active'], DB_SQL_Operator::_LESS_THAN_, time() - $expires)->execute();
 }
Example #2
0
 /**
  * This function logs the current user out.
  *
  * @access public
  * @param boolean $destroy                  whether the session is to be to completely
  *                                          destroyed
  * @param boolean $logout_all               whether all tokens for user are to be removed
  * @param boolean                           whether the logout was successful
  */
 public function logout($destroy = FALSE, $logout_all = FALSE)
 {
     // Set by force_login()
     $this->_session->delete('auth_forced');
     if ($token = Cookie::get('authautologin')) {
         // Delete the autologin cookie to prevent re-login
         Cookie::delete('authautologin');
         // Clear the autologin token from the database
         $token = DB_ORM::select($this->models['token'])->where($this->columns['token'], DB_SQL_Operator::_EQUAL_TO_, $token)->limit(1)->query()->fetch(0);
         $token_model = DB_ORM_Model::model_name($this->models['token']);
         if ($logout_all) {
             DB_ORM::delete($this->models['token'])->where($this->columns['user_id'], DB_SQL_Operator::_EQUAL_TO_, $token->user)->execute();
         } else {
             if ($token instanceof $token_model and $token->is_loaded()) {
                 $token->delete();
             }
         }
     }
     return parent::logout($destroy);
 }