Index: trunk/core/kernel/session/session.php =================================================================== diff -u -N -r6685 -r6833 --- trunk/core/kernel/session/session.php (.../session.php) (revision 6685) +++ trunk/core/kernel/session/session.php (.../session.php) (revision 6833) @@ -66,6 +66,8 @@ var $DirectVars = Array(); var $ChangedDirectVars = Array(); + var $PersistentVars = Array (); + var $OriginalData=Array(); var $TimestampField; @@ -248,6 +250,52 @@ } return $expired_sids; } + + function LoadPersistentVars(&$session) + { + $user_id = $this->Application->GetVar('u_id'); + if ($user_id != -2) { + // root & normal users + $sql = 'SELECT VariableValue, VariableName + FROM '.TABLE_PREFIX.'PersistantSessionData + WHERE PortalUserId = '.$user_id; + $this->PersistentVars = $this->Conn->GetCol($sql, 'VariableName'); + } + else { + $this->PersistentVars = Array (); + } + } + + function StorePersistentVar(&$session, $var_name, $var_value) + { + $this->PersistentVars[$var_name] = $var_value; + + $replace_hash = Array ( + 'PortalUserId' => $this->Application->GetVar('u_id'), + 'VariableName' => $var_name, + 'VariableValue' => $var_value + ); + $this->Conn->doInsert($replace_hash, TABLE_PREFIX.'PersistantSessionData', 'REPLACE'); + + } + + function RecallPersistentVar(&$session, $var_name, $default = false) + { + return isset($this->PersistentVars[$var_name]) ? $this->PersistentVars[$var_name] : $default; + } + + function RemovePersistentVar(&$session, $var_name) + { + unset($this->PersistentVars[$var_name]); + + $user_id = $this->Application->GetVar('u_id'); + + if ($user_id != -2) { + $sql = 'DELETE FROM '.TABLE_PREFIX.'PersistantSessionData + WHERE PortalUserId = '.$user_id.' AND VariableName = '.$this->Conn->qstr($var_name); + $this->Conn->Query($sql); + } + } } define('smAUTO', 1); @@ -676,6 +724,7 @@ function PrintSession($comment='') { if($this->Application->isDebugMode() && constOn('DBG_SHOW_SESSIONDATA')) { + // dump session data $this->Application->Debugger->appendHTML('SessionStorage ('.$comment.'):'); $session_data = $this->Data->GetParams(); ksort($session_data); @@ -686,10 +735,22 @@ } $this->Application->Debugger->dumpVars($session_data); - // to insert after HTTPQuery if it's visible - $new_row = constOn('DBG_SHOW_HTTPQUERY') ? 4 : 2; - - //$debugger->moveAfterRow($new_row,2); + // dump persistent session data + if ($this->Storage->PersistentVars) { + $this->Application->Debugger->appendHTML('Persistant Session:'); + $session_data = $this->Storage->PersistentVars; + ksort($session_data); + foreach ($session_data as $session_key => $session_value) { + if (IsSerialized($session_value)) { + $session_data[$session_key] = unserialize($session_value); + } + } + $this->Application->Debugger->dumpVars($session_data); + } + +// to insert after HTTPQuery if it's visible +// $new_row = constOn('DBG_SHOW_HTTPQUERY') ? 4 : 2; +// $debugger->moveAfterRow($new_row,2); } } @@ -717,7 +778,17 @@ { $this->Data->Set($name, $value); } - + + function StorePersistentVar($name, $value) + { + $this->Storage->StorePersistentVar($this, $name, $value); + } + + function LoadPersistentVars() + { + $this->Storage->LoadPersistentVars($this); + } + function StoreVarDefault($name, $value) { $tmp = $this->RecallVar($name); @@ -727,18 +798,28 @@ } } - function RecallVar($name,$default=false) + function RecallVar($name, $default = false) { $ret = $this->Data->Get($name); - return ($ret===false) ? $default : $ret; + return ($ret === false) ? $default : $ret; } + function RecallPersistentVar($name, $default = false) + { + return $this->Storage->RecallPersistentVar($this, $name, $default); + } + function RemoveVar($name) { $this->Storage->RemoveFromData($this, $name); $this->Data->Remove($name); } + function RemovePersistentVar($name) + { + return $this->Storage->RemovePersistentVar($this, $name); + } + /** * Ignores session varible value set before *