示例#1
0
function restoreOldSession($sessionData, $userid, $domain, $dbLink, $params = array())
{
    $data = $_ENV['AUTH-DATA'];
    $sessionID = $sessionData['token'];
    $q1 = $dbLink->_selectQ(_dbTable("log_sessions", true), "*", array("sessionid" => $sessionID, "user" => $userid, "client" => _server('REMOTE_ADDR'), "user_agent" => _server('HTTP_USER_AGENT')));
    $result = $dbLink->executeQuery($q1);
    if ($result) {
        $logData = $dbLink->fetchAllData($result);
        $dbLink->freeResult($result);
        if ($logData != null && count($logData) > 0) {
            $logData = $logData[0];
            $logData['session_data'] = stripslashes($logData['session_data']);
            $logData['session_data'] = json_decode($logData['session_data'], true);
            session_regenerate_id();
            foreach ($logData['session_data'] as $key => $value) {
                $_SESSION[$key] = $value;
            }
            setcookie("LOGIN", "true", time() + 36000);
            setcookie("USER", $_SESSION['SESS_USER_ID'], time() + 36000);
            setcookie("TOKEN", $_SESSION['SESS_TOKEN'], time() + 36000);
            setcookie("SITE", $_SESSION['SESS_LOGIN_SITE'], time() + 36000);
            //$logData['global_data']$GLOBALS
            //printArray($_SESSION);exit();
            gotoSuccessLink();
        } else {
            logoutOldSessions($userid, $domain, $dbLink, $params);
            startNewSession($userid, $domain, $dbLink, $params);
        }
    } else {
        logoutOldSessions($userid, $domain, $dbLink, $params);
        startNewSession($userid, $domain, $dbLink, $params);
    }
    exit;
}
示例#2
0
function restoreOldSession($sessionData, $userid, $domain, $params = array())
{
    $data = $_ENV['AUTH-DATA'];
    $sessionID = $sessionData['token'];
    $logData = _db(true)->_selectQ(_dbTable("cache_sessions", true), "*", array("session_key" => $sessionID, "userid" => $userid, "site" => $domain, "device" => getUserDeviceType(), "client_ip" => $_SERVER['REMOTE_ADDR']))->_get();
    if (!empty($logData)) {
        $logData = $logData[0];
        $logData['session_data'] = stripslashes($logData['session_data']);
        $logData['session_data'] = json_decode($logData['session_data'], true);
        session_regenerate_id();
        foreach ($logData['session_data'] as $key => $value) {
            $_SESSION[$key] = $value;
        }
        setcookie("LOGIN", "true", time() + 36000);
        setcookie("USER", $_SESSION['SESS_USER_ID'], time() + 36000);
        setcookie("TOKEN", $_SESSION['SESS_TOKEN'], time() + 36000);
        setcookie("SITE", $_SESSION['SESS_LOGIN_SITE'], time() + 36000);
        //$logData['global_data']$GLOBALS
        //printArray($_SESSION);exit();
        gotoSuccessLink();
    } else {
        logoutOldSessions($userid, $domain, $params);
        startNewSession($userid, $domain, $params);
    }
}