[BUGFIX] FE session records are never removed 56/16956/2
authorSteffen Müller <typo3@t3node.com>
Sat, 17 Mar 2012 14:43:23 +0000 (15:43 +0100)
committerDmitry Dulepov <dmitry@typo3.org>
Thu, 20 Dec 2012 09:03:43 +0000 (10:03 +0100)
The FE session records are never removed,
even if no session data are left.

Change-Id: Ic30acd00b9e5bfd09910d5e070b67f4dc865030e
Fixes: #34964
Releases: 4.5, 4.6, 4.7, 6.0, 6.1
Reviewed-on: https://review.typo3.org/16956
Reviewed-by: Dmitry Dulepov
Tested-by: Dmitry Dulepov
typo3/sysext/cms/tslib/class.tslib_feuserauth.php

index f20544d..a41727c 100644 (file)
@@ -397,9 +397,14 @@ class tslib_feUserAuth extends t3lib_userAuth {
                if ($this->userData_change)     {
                        $this->writeUC('');
                }
-               if ($this->sesData_change)      {
-                       if ($this->id)  {
-                               $insertFields = array (
+
+               if ($this->sesData_change && $this->id) {
+                       if (empty($this->sesData)) {
+                               // Remove session-data
+                               $this->removeSessionData();
+                       } elseif ($this->sessionDataTimestamp === NULL) {
+                                       // Write new session-data
+                               $insertFields = array(
                                        'hash' => $this->id,
                                        'content' => serialize($this->sesData),
                                        'tstamp' => $GLOBALS['EXEC_TIME'],
@@ -473,12 +478,20 @@ class tslib_feUserAuth extends t3lib_userAuth {
                        switch($type)   {
                                case 'user':
                                        if ($this->user['uid']) {
-                                               $this->uc[$key]=$data;
+                                               if ($data === NULL) {
+                                                       unset($this->uc[$key]);
+                                               } else {
+                                                       $this->uc[$key] = $data;
+                                               }
                                                $this->userData_change=1;
                                        }
                                break;
                                case 'ses':
-                                       $this->sesData[$key]=$data;
+                                       if ($data === NULL) {
+                                               unset($this->sesData[$key]);
+                                       } else {
+                                               $this->sesData[$key] = $data;
+                                       }
                                        $this->sesData_change=1;
                                break;
                        }