Index: branches/5.1.x/core/kernel/session/session.php =================================================================== diff -u -N -r13880 -r14135 --- branches/5.1.x/core/kernel/session/session.php (.../session.php) (revision 13880) +++ branches/5.1.x/core/kernel/session/session.php (.../session.php) (revision 14135) @@ -1,6 +1,6 @@ Application->TableFound($this->TableName)) { - return false; - } - $fields_hash = Array ( $this->IDField => $session->SID, $this->TimestampField => $session->Expiration, @@ -152,13 +148,24 @@ $fields_hash['BrowserSignature'] = $this->_getBrowserSignature(); } - // default values + additional values + values set during this script run - $additional_fields = array_merge($additional_fields, $this->DirectVars); // used 2 times later - $fields_hash = array_merge($fields_hash, $additional_fields); + // default values + values set during this script run - $this->Conn->doInsert($fields_hash, $this->TableName); + return array_merge($fields_hash, $this->DirectVars); + } - foreach ($additional_fields as $field_name => $field_value) { + function StoreSession(&$session, $to_database = true) + { + if (defined('IS_INSTALL') && IS_INSTALL && $to_database && !$this->Application->TableFound($this->TableName)) { + return false; + } + + $fields_hash = $this->GetSessionDefaults($session); + + if ($to_database) { + $this->Conn->doInsert($fields_hash, $this->TableName); + } + + foreach ($fields_hash as $field_name => $field_value) { $this->SetField($session, $field_name, $field_value); } } @@ -285,9 +292,13 @@ function RemoveFromData(&$session, $var) { - $query = 'DELETE FROM '.$this->SessionDataTable.' WHERE '.$this->IDField.' = '.$this->Conn->qstr($session->SID). - ' AND '.$this->DataVarField.' = '.$this->Conn->qstr($var); - $this->Conn->Query($query); + if ($session->SessionSet) { + // only, when session is stored in database + $sql = 'DELETE FROM ' . $this->SessionDataTable . ' + WHERE ' . $this->IDField . ' = ' . $this->Conn->qstr($session->SID) . ' AND ' . $this->DataVarField . ' = ' . $this->Conn->qstr($var); + $this->Conn->Query($sql); + } + unset($this->OriginalData[$var]); } @@ -960,7 +971,9 @@ return true; } - if (!$force && !($this->Application->isAdmin || $this->Application->GetVar('admin')) && !$this->NeedSession()) { + $this->Expiration = adodb_mktime() + $this->SessionTimeout; + + if (!$force && /*!$this->Application->isAdmin &&*/ !$this->Application->GetVar('admin') && !$this->NeedSession()) { // don't create session (in db) on Front-End, when sid is present (GPC), but data in db isn't if ($this->_fromGet) { // set sid, that was given in GET @@ -969,15 +982,16 @@ // re-generate sid only, when cookies are used $this->GenerateSID(); } + + $this->Storage->StoreSession($this, false); + return false; } if (!$this->SID || $force) { $this->GenerateSID(); } - $this->Expiration = adodb_mktime() + $this->SessionTimeout; - switch ($this->Mode) { case smAUTO: if ($this->CookiesEnabled) { Index: branches/5.1.x/core/units/helpers/user_helper.php =================================================================== diff -u -N -r14106 -r14135 --- branches/5.1.x/core/units/helpers/user_helper.php (.../user_helper.php) (revision 14106) +++ branches/5.1.x/core/units/helpers/user_helper.php (.../user_helper.php) (revision 14135) @@ -1,6 +1,6 @@ Application->ConfigValue('User_LoggedInGroup') ); - $this->Application->StoreVar( 'UserGroups', implode(',', $groups) ); + $this->Application->StoreVar( 'UserGroups', implode(',', $groups), true ); // true for optional return $this->Application->CheckPermission($this->Application->isAdmin ? 'ADMIN' : 'LOGIN', 1); } Index: branches/5.1.x/core/kernel/db/dbitem.php =================================================================== diff -u -N -r13952 -r14135 --- branches/5.1.x/core/kernel/db/dbitem.php (.../dbitem.php) (revision 13952) +++ branches/5.1.x/core/kernel/db/dbitem.php (.../dbitem.php) (revision 14135) @@ -1,6 +1,6 @@ Application->GetTopmostPrefix($this->Prefix); - $this->Application->StoreVar($main_prefix . '_modified', '1', !$this->Application->isAdmin); + $this->Application->StoreVar($main_prefix . '_modified', '1', true); // true for optional if ($this->ShouldLogChanges(true)) { $this->LogChanges($main_prefix, $mode); Index: branches/5.1.x/core/units/user_groups/user_groups_eh.php =================================================================== diff -u -N -r13086 -r14135 --- branches/5.1.x/core/units/user_groups/user_groups_eh.php (.../user_groups_eh.php) (revision 13086) +++ branches/5.1.x/core/units/user_groups/user_groups_eh.php (.../user_groups_eh.php) (revision 14135) @@ -1,6 +1,6 @@ Application->StoreVar($this->Application->GetTopmostPrefix($event->Prefix).'_modified', '1'); + $this->Application->StoreVar($this->Application->GetTopmostPrefix($event->Prefix).'_modified', '1', true); // true for optional $event->SetRedirectParam('opener', 'u'); } Index: branches/5.1.x/core/kernel/session/inp_session.php =================================================================== diff -u -N -r13581 -r14135 --- branches/5.1.x/core/kernel/session/inp_session.php (.../inp_session.php) (revision 13581) +++ branches/5.1.x/core/kernel/session/inp_session.php (.../inp_session.php) (revision 14135) @@ -1,6 +1,6 @@ $this->Application->isAdmin ? 0 : USER_GUEST, @@ -122,7 +121,7 @@ 'GroupList' => $this->Application->ConfigValue('User_GuestGroup'), ); - parent::StoreSession($session, $fields_hash); + return array_merge($fields_hash, parent::GetSessionDefaults($session)); } function GetExpiredSIDs()