diff --git a/typo3/sysext/cms/tslib/class.tslib_feuserauth.php b/typo3/sysext/cms/tslib/class.tslib_feuserauth.php index f20544d..6cc6184 100644 --- a/typo3/sysext/cms/tslib/class.tslib_feuserauth.php +++ b/typo3/sysext/cms/tslib/class.tslib_feuserauth.php @@ -399,13 +399,15 @@ class tslib_feUserAuth extends t3lib_userAuth { } if ($this->sesData_change) { if ($this->id) { - $insertFields = array ( - 'hash' => $this->id, - 'content' => serialize($this->sesData), - 'tstamp' => $GLOBALS['EXEC_TIME'], - ); $this->removeSessionData(); - $GLOBALS['TYPO3_DB']->exec_INSERTquery('fe_session_data', $insertFields); + if (!empty($this->sesData)) { + $insertFields = array ( + 'hash' => $this->id, + 'content' => serialize($this->sesData), + 'tstamp' => $GLOBALS['EXEC_TIME'], + ); + $GLOBALS['TYPO3_DB']->exec_INSERTquery('fe_session_data', $insertFields); + } } } } @@ -463,23 +465,31 @@ class tslib_feUserAuth extends t3lib_userAuth { * Notice: Simply calling this function will not save the data to the database! The actual saving is done in storeSessionData() which is called as some of the last things in index_ts.php. So if you exit before this point, nothing gets saved of course! And the solution is to call $GLOBALS['TSFE']->storeSessionData(); before you exit. * * @param string Session data type; Either "user" (persistent, bound to fe_users profile) or "ses" (temporary, bound to current session cookie) - * @param string Key from the data array to store incoming data in; The session data (in either case) is an array ($this->uc / $this->sesData) and this value determines in which key the $data value will be stored. + * @param string Key from the data array to store incoming data in; The session data (in either case) is an array ($this->uc / $this->sesData) and this value determines in which key the $data value will be stored. If data is NULL, the key is removed * @param mixed The data value to store in $key * @return void * @see setKey(), storeSessionData(), record_registration() */ - function setKey($type,$key,$data) { - if ($key) { - switch($type) { + function setKey($type, $key, $data) { + if ($key) { + switch($type) { case 'user': if ($this->user['uid']) { - $this->uc[$key]=$data; - $this->userData_change=1; + if ($data === NULL) { + unset($this->uc[$key]); + } else { + $this->uc[$key] = $data; + } + $this->userData_change = 1; } break; case 'ses': - $this->sesData[$key]=$data; - $this->sesData_change=1; + if ($data === NULL) { + unset($this->sesData[$key]); + } else { + $this->sesData[$key] = $data; + } + $this->sesData_change = 1; break; } }