public static function init_empty_session() {
        global $CFG;

        if (isset($GLOBALS['SESSION']->notifications)) {
            // Backup notifications. These should be preserved across session changes until the user fetches and clears them.
            $notifications = $GLOBALS['SESSION']->notifications;
        }
        $GLOBALS['SESSION'] = new \stdClass();

        $GLOBALS['USER'] = new \stdClass();
        $GLOBALS['USER']->id = 0;

        if (!empty($notifications)) {
            // Restore notifications.
            $GLOBALS['SESSION']->notifications = $notifications;
        }
        if (isset($CFG->mnet_localhost_id)) {
            $GLOBALS['USER']->mnethostid = $CFG->mnet_localhost_id;
        } else {
            // Not installed yet, the future host id will be most probably 1.
            $GLOBALS['USER']->mnethostid = 1;
        }

        // Link global $USER and $SESSION.
        $_SESSION = array();
        $_SESSION['USER'] =& $GLOBALS['USER'];
        $_SESSION['SESSION'] =& $GLOBALS['SESSION'];
    }
public static function init_empty_session() {
        global $CFG;

        if (isset($GLOBALS['SESSION']->notifications)) {
            // Backup notifications. These should be preserved across session changes until the user fetches and clears them.
            $notifications = $GLOBALS['SESSION']->notifications;
        }
        $GLOBALS['SESSION'] = new \stdClass();

        $GLOBALS['USER'] = new \stdClass();
        $GLOBALS['USER']->id = 0;

        if (!empty($notifications)) {
            // Restore notifications.
            $GLOBALS['SESSION']->notifications = $notifications;
        }
        if (isset($CFG->mnet_localhost_id)) {
            $GLOBALS['USER']->mnethostid = $CFG->mnet_localhost_id;
        } else {
            // Not installed yet, the future host id will be most probably 1.
            $GLOBALS['USER']->mnethostid = 1;
        }

        // Link global $USER and $SESSION.
        $_SESSION = array();
        $_SESSION['USER'] =& $GLOBALS['USER'];
        $_SESSION['SESSION'] =& $GLOBALS['SESSION'];
    }
public static function init_empty_session ( ) { global $ CFG ; if ( isset ( $ GLOBALS [ 'SESSION' ] -> notifications ) ) { // Backup notifications. These should be preserved across session changes until the user fetches and clears them. $ notifications = $ GLOBALS [ 'SESSION' ] -> notifications ; } $ GLOBALS [ 'SESSION' ] = new \ stdClass ( ) ; $ GLOBALS [ 'USER' ] = new \ stdClass ( ) ; $ GLOBALS [ 'USER' ] -> id = 0 ; if ( ! empty ( $ notifications ) ) { // Restore notifications. $ GLOBALS [ 'SESSION' ] -> notifications = $ notifications ; } if ( isset ( $ CFG -> mnet_localhost_id ) ) { $ GLOBALS [ 'USER' ] -> mnethostid = $ CFG -> mnet_localhost_id ; } else { // Not installed yet, the future host id will be most probably 1. $ GLOBALS [ 'USER' ] -> mnethostid = 1 ; } // Link global $USER and $SESSION. $ _SESSION = array ( ) ; $ _SESSION [ 'USER' ] = & $ GLOBALS [ 'USER' ] ; $ _SESSION [ 'SESSION' ] = & $ GLOBALS [ 'SESSION' ] ; }
Empty current session, fill it with not-logged-in user info.

This is intended for installation scripts, unit tests and other
special areas. Do NOT use for logout and session termination
in normal requests!
Empty current session fill it with not - logged - in user info .