Ejemplo n.º 1
0
/**
 * Actual login!  Performs the login of a user using pre-vetted info!
 * Creates the cookie and session stuff for the login process.
**/
function _login_user($p_username, $p_player_id, $p_account_id)
{
    if (!$p_username || !$p_player_id || !$p_account_id) {
        throw new Exception('Request made to _login_user without all of username, player_id, and account_id being set.');
    }
    SESSION::commence();
    // Start a session on a successful login.
    $_COOKIE['username'] = $p_username;
    // May want to keep this for relogin easing purposes.
    SESSION::set('username', $p_username);
    // Actually char name
    SESSION::set('player_id', $p_player_id);
    // Actually char id.
    SESSION::set('account_id', $p_account_id);
    update_activity_log($p_player_id);
    update_last_logged_in($p_player_id);
    $up = "UPDATE players SET active = 1 WHERE player_id = :char_id";
    query($up, array(':char_id' => array($p_player_id, PDO::PARAM_INT)));
}
Ejemplo n.º 2
0
function nw_session_start($potential_username = '')
{
    $result = array('cookie_created' => false, 'session_existed' => false, 'cookie_existed' => false);
    if (!isset($_COOKIE['user_cookie']) || $_COOKIE['user_cookie'] != $potential_username) {
        // Refresh cookie if the username isn't set in it yet.
        $result['cookie_created'] = createCookie("user_cookie", $potential_username, time() + 60 * 60 * 24 * 365, "/", WEB_ROOT);
        // *** 360 days ***
    } else {
        $result['cookie_existed'] = true;
    }
    if ($potential_username) {
        SESSION::set('username', $potential_username);
    } else {
        SESSION::commence();
    }
    return $result;
}