Пример #1
0
/**
 *	session_set_new() - Setup session for the given user
 *
 *	This function sets up SourceForge session for the given user,
 *	making one be "logged in".
 *
 *	@param		int		The user ID
 *	@return none
 */
function session_set_new($user_id)
{
    global $G_SESSION;
    // set session cookie
    //
    $cookie = session_build_session_cookie($user_id);
    session_cookie("session_ser", $cookie);
    db_query("\n\t\tINSERT INTO session (session_hash, ip_addr, time, user_id) \n\t\tVALUES (\n\t\t\t'" . session_get_session_cookie_hash($cookie) . "', \n\t\t\t'" . $GLOBALS['REMOTE_ADDR'] . "',\n\t\t\t'" . time() . "',\n\t\t\t{$user_id}\n\t\t)\n\t");
    // check uniqueness of the session_hash in the database
    //
    $res = session_getdata($user_id);
    if (!$res || db_numrows($res) < 1) {
        exit_error("ERROR", "ERROR - Cannot initialize session: " . db_error());
    } else {
        //set up the new user object
        //
        $G_SESSION = user_get_object($user_id, $res);
        if ($G_SESSION) {
            $G_SESSION->setLoggedIn(true);
        }
    }
    // set username cookie for *.hostname.tld, expiration set in local.inc
    //
    session_cookie('username', session_build_username_cookie($G_SESSION->getUnixName()), $GLOBALS['sys_username_cookie_urlspace'], time() + $GLOBALS['sys_username_cookie_expiration']);
}
Пример #2
0
/**
 *	session_set_new() - Setup session for the given user
 *
 *	This function sets up SourceForge session for the given user,
 *	making one be "logged in".
 *
 *	@param		int		The user ID
 *	@return none
 */
function session_set_new($user_id)
{
    global $G_SESSION, $session_ser;
    // set session cookie
    //
    $cookie = session_build_session_cookie($user_id);
    session_cookie("session_ser", $cookie, "", $GLOBALS['sys_session_expire']);
    $session_ser = $cookie;
    db_query("\n\t\tINSERT INTO user_session (session_hash, ip_addr, time, user_id) \n\t\tVALUES (\n\t\t\t'" . session_get_session_cookie_hash($cookie) . "', \n\t\t\t'" . getStringFromServer('REMOTE_ADDR') . "',\n\t\t\t'" . time() . "',\n\t\t\t{$user_id}\n\t\t)\n\t");
    // check uniqueness of the session_hash in the database
    //
    $res = session_getdata($user_id);
    if (!$res || db_numrows($res) < 1) {
        exit_error(_('ERROR'), _('ERROR') . ": " . db_error());
    } else {
        //set up the new user object
        //
        $G_SESSION = user_get_object($user_id, $res);
        if ($G_SESSION) {
            $G_SESSION->setLoggedIn(true);
        }
    }
}