function login_processing2($firstname = false, $surname = false, $username = false)
{
    global $authmech, $errors, $xerte_toolkits_site;
    if (!isset($_SESSION['toolkits_logon_username'])) {
        $_SESSION['toolkits_firstname'] = $firstname == false ? $authmech->getFirstname() : $firstname;
        $_SESSION['toolkits_surname'] = $surname == false ? $authmech->getSurname() : $surname;
        $_SESSION['toolkits_logon_username'] = $username == false ? $authmech->getUsername() : $username;
    }
    require_once dirname(__FILE__) . '/user_library.php';
    /*
     * Check to see if this is a users' first time on the site
     */
    if (check_if_first_time($_SESSION['toolkits_logon_username'])) {
        /*
         *      create the user a new id
         */
        $_SESSION['toolkits_logon_id'] = create_user_id($_SESSION['toolkits_logon_username'], $_SESSION['toolkits_firstname'], $_SESSION['toolkits_surname']);
        /*
         *   create a virtual root folder for this user
         */
        create_a_virtual_root_folder();
    } else {
        /*
         * User exists so update the user settings
         */
        $_SESSION['toolkits_logon_id'] = get_user_id();
        update_user_logon_time();
    }
}
    $time2 = time();
    $timediff = $time2 - $time1;
    $needreauth = false;
    // reauthenticate after 15 weeks ( 60 seconds * 60 mins = 1 hour * 24 hours = 1 day * 7 days = 1 week * 15 = 15 weeks )
    if ($timediff > 60 * 60 * 24 * 7 * 15) {
        //if ($timediff > (60 * 60 * 1)) {
        $needreauth = true;
    }
    //if needreauth then do authentication again else  $returned[0] has the user in it do appropriate things
    if ($needreauth) {
        auth(true);
    }
    require_once '../' . $xerte_toolkits_site->php_library_path . '/user_library.php';
    $data = get_user_info();
    login_processing2($data[0], $data[1], $data[2]);
    update_user_logon_time();
}
// if xerteID set then store the associated data
if (isset($_REQUEST['xerteID'])) {
    $retlookup = $_SESSION['postlookup'][$_REQUEST['xerteID']];
    unset($_SESSION['postlookup']);
    if ($retlookup > 0) {
        //$info = $lti->getResourceKey(1);
        $lti->add_lti_resource($retlookup, 'xerte');
    }
}
// check resource status
$returned = $lti->lookup_lti_resource();
if (!$lti->isInstructor()) {
    //student
    if ($returned === false) {