diff --git a/kernel/classes/datatypes/ezuser/ezuser.php b/kernel/classes/datatypes/ezuser/ezuser.php
index 99d1ca1edd520f75ab260e8a1f0666a5f1c5c414..d401d7de5d3211bb5f280fbab06e0d258496f91f 100644
--- a/kernel/classes/datatypes/ezuser/ezuser.php
+++ b/kernel/classes/datatypes/ezuser/ezuser.php
@@ -1195,9 +1195,10 @@ WHERE user_id = '" . $userID . "' AND
                 if ( $ssoUser !== false )
                 {
                     $currentUser = $ssoUser;
+                    $userId = $currentUser->attribute( 'contentobject_id' );
 
                     $userInfo = array();
-                    $userInfo[$userId] = array( 'contentobject_id' => $currentUser->attribute( 'contentobject_id' ),
+                    $userInfo[$userId] = array( 'contentobject_id' => $userId,
                                             'login' => $currentUser->attribute( 'login' ),
                                             'email' => $currentUser->attribute( 'email' ),
                                             'password_hash' => $currentUser->attribute( 'password_hash' ),
@@ -1208,10 +1209,10 @@ WHERE user_id = '" . $userID . "' AND
                     $http->setSessionVariable( 'eZUserInfoCache_Timestamp', time() );
                     $http->setSessionVariable( 'eZUserLoggedInID', $userId );
 
-                    eZUser::updateLastVisit( $currentUser->attribute( 'contentobject_id' ) );
-                    eZUser::setCurrentlyLoggedInUser( $currentUser, $currentUser->attribute( 'contentobject_id' ) );
+                    eZUser::updateLastVisit( $userId );
+                    eZUser::setCurrentlyLoggedInUser( $currentUser, $userId );
                     eZHTTPTool::redirect( eZSys::wwwDir() . eZSys::indexFile( false ) . eZSys::requestURI(), array(), 302 );
-
+                    eZExecution::cleanExit();
                 }
             }
         }
