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');
            }
        }
    }
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');
            }
        }
    }
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' ) ; } } }
Do various session security checks.

WARNING: $USER and $SESSION are set up later, do not use them yet!
@throws \core\session\exception
Do various session security checks .