Exemplo n.º 1
0
function mp_set_categoryid($categoryid)
{
    /*
     *	set the categoryid
     */
    qa_start_session();
    $suffix = qa_session_var_suffix();
    // lets check if we have a cookie defined already
    if (!empty($_COOKIE['qa_session'])) {
        @(list($handle, $sessioncode, $remember, $oldcategoryid) = explode('/', $_COOKIE['qa_session']));
        qa_set_session_cookie($handle, $sessioncode, $remember, $categoryid);
    }
    $_SESSION['mp_session_category_id_' . $suffix] = $categoryid;
}
Exemplo n.º 2
0
 function qa_get_logged_in_userid()
 {
     if (qa_to_override(__FUNCTION__)) {
         $args = func_get_args();
         return qa_call_override(__FUNCTION__, $args);
     }
     global $qa_logged_in_userid_checked;
     $suffix = qa_session_var_suffix();
     if (!$qa_logged_in_userid_checked) {
         // only check once
         qa_start_session();
         // this will load logged in userid from the native PHP session, but that's not enough
         $sessionuserid = @$_SESSION['qa_session_userid_' . $suffix];
         if (isset($sessionuserid)) {
             // check verify code matches
             if (@$_SESSION['qa_session_verify_' . $suffix] != qa_session_verify_code($sessionuserid)) {
                 qa_clear_session_user();
             }
         }
         if (!empty($_COOKIE['qa_session'])) {
             @(list($handle, $sessioncode, $remember) = explode('/', $_COOKIE['qa_session']));
             if ($remember) {
                 qa_set_session_cookie($handle, $sessioncode, $remember);
             }
             // extend 'remember me' cookies each time
             $sessioncode = trim($sessioncode);
             // trim to prevent passing in blank values to match uninitiated DB rows
             // Try to recover session from the database if PHP session has timed out
             if (!isset($_SESSION['qa_session_userid_' . $suffix]) && !empty($handle) && !empty($sessioncode)) {
                 require_once QA_INCLUDE_DIR . 'db/selects.php';
                 $userinfo = qa_db_single_select(qa_db_user_account_selectspec($handle, false));
                 // don't get any pending
                 if (strtolower(trim($userinfo['sessioncode'])) == strtolower($sessioncode)) {
                     qa_set_session_user($userinfo['userid'], $userinfo['sessionsource']);
                 } else {
                     qa_clear_session_cookie();
                 }
                 // if cookie not valid, remove it to save future checks
             }
         }
         $qa_logged_in_userid_checked = true;
     }
     return @$_SESSION['qa_session_userid_' . $suffix];
 }