Changeset 10050

Show
Ignore:
Timestamp:
11/29/08 18:36:01 (1 month ago)
Author:
afz
Message:

Update session stuff

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/jaws/html/include/Jaws/Session/Cache.php

    r9990 r10050  
    217217    function GetSession($sid) 
    218218    { 
    219         $params        = array(); 
     219        $params = array(); 
    220220        $params['sid'] = $sid; 
    221221 
    222222        $sql = ' 
    223            SELECT [session_id], [user_id], [hash], [md5] 
    224            FROM [[session]] 
    225            WHERE [session_id] = {sid}'; 
     223            SELECT 
     224                [session_id], [user_id], [hash], [md5], [updatetime], [life_time] 
     225            FROM [[session]] 
     226            WHERE 
     227                [session_id] = {sid}'; 
    226228 
    227229        $result = $GLOBALS['db']->queryRow($sql, $params); 
    228         if (Jaws_Error::isError($result) || !isset($result['session_id'])) { 
    229             return false; 
    230         } 
    231  
    232         return $result; 
     230        if (!Jaws_Error::isError($result) && isset($result['session_id'])) { 
     231            $expired = time() - ($GLOBALS['app']->Registry->Get('Session/idle_timeout') * 60); 
     232            if ($result['updatetime'] >= ($expired - $result['life_time'])) { 
     233                return $result; 
     234            } 
     235        } 
     236 
     237        return false; 
    233238    } 
    234239 
  • trunk/jaws/html/include/Jaws/Session/Web.php

    r9990 r10050  
    2828    function init() 
    2929    { 
    30         $session_id = $this->GetCookie(JAWS_SESSION_ID); 
    31         if ($session_id === false || !$this->Load($session_id)) { 
    32             if ($this->Create('', false) && $this->Load($this->_SessionID)) { 
    33                 $session_id = $this->_SessionID; 
    34             } else { 
    35                 $session_id = false; 
    36             } 
    37         } 
    38  
    39         if ($session_id) { 
     30        $session = $this->GetCookie(JAWS_SESSION_ID); 
     31        if ($session === false || !$this->Load($session)) { 
     32            $this->Create(''); 
     33            $this->_Logged = false; 
     34        } else { 
    4035            $this->_Logged = $this->GetAttribute('logged'); 
    41         } else { 
    42             $this->_Logged = false; 
    4336        } 
    4437    } 
     
    8376        $version = $GLOBALS['app']->Registry->Get('Session/cookie_version'); 
    8477        $name    = $name.'_'.md5($GLOBALS['app']->getSiteURL().'_'.$version); 
    85         setcookie($name, $value, (($minutes ==0)? 0 : time() +(60 * $minutes)), $GLOBALS['app']->getSiteURL(true, true) . '/'); 
     78        setcookie($name, $value, ($minutes == 0)? 0 : (time() + $minutes*60), $GLOBALS['app']->getSiteURL(true, true) . '/'); 
    8679    } 
    8780