original_string: protected static function check_security() {
          global $CFG;
  
          if (!empty($_SESSION['USER']->id) and !empty($CFG->tracksessionip)) {
              // Make sure current IP matches the one for this session.
              $remoteaddr = getremoteaddr();
  
              if (empty($_SESSION['USER']->sessionip)) {
                  $_SESSION['USER']->sessionip = $remoteaddr;
              }
  
              if ($_SESSION['USER']->sessionip != $remoteaddr) {
                  // This is a security feature - terminate the session in case of any doubt.
                  self::terminate_current();
                  throw new exception('sessionipnomatch2', 'error');
              }
          }
      }
code: protected static function check_security() {
          global $CFG;
  
          if (!empty($_SESSION['USER']->id) and !empty($CFG->tracksessionip)) {
              // Make sure current IP matches the one for this session.
              $remoteaddr = getremoteaddr();
  
              if (empty($_SESSION['USER']->sessionip)) {
                  $_SESSION['USER']->sessionip = $remoteaddr;
              }
  
              if ($_SESSION['USER']->sessionip != $remoteaddr) {
                  // This is a security feature - terminate the session in case of any doubt.
                  self::terminate_current();
                  throw new exception('sessionipnomatch2', 'error');
              }
          }
      }
code_tokens: protected static function check_security ( ) { global $ CFG ; if ( ! empty ( $ _SESSION [ 'USER' ] -> id ) and ! empty ( $ CFG -> tracksessionip ) ) { // Make sure current IP matches the one for this session. $ remoteaddr = getremoteaddr ( ) ; if ( empty ( $ _SESSION [ 'USER' ] -> sessionip ) ) { $ _SESSION [ 'USER' ] -> sessionip = $ remoteaddr ; } if ( $ _SESSION [ 'USER' ] -> sessionip != $ remoteaddr ) { // This is a security feature - terminate the session in case of any doubt. self :: terminate_current ( ) ; throw new exception ( 'sessionipnomatch2' , 'error' ) ; } } }
docstring: Do various session security checks.
  
  WARNING: $USER and $SESSION are set up later, do not use them yet!
  @throws \core\session\exception
docstring_tokens: Do various session security checks .