title: typo3 7 + extbase: manually login frontend user
body: <p>I'm trying to manually login a frontend user (and do some other basic operations while I'm at it) in an <code>ajaxAction</code> and it doesn't seem to work as I intend. What I do when the loginform is submitted: </p>
  
  <pre><code>$loginData = array(
      'username' =&gt; $username,
      'uident_text' =&gt; $password,
      'status' =&gt; 'login',
  );
  
  $GLOBALS['TSFE']-&gt;fe_user-&gt;checkPid = 0;
  $info = $GLOBALS['TSFE']-&gt;fe_user-&gt;getAuthInfoArray();
  $user = $GLOBALS['TSFE']-&gt;fe_user-&gt;fetchUserRecord($info['db_user'], $loginData['username']);
  
  $GLOBALS['TSFE']-&gt;loginUser = 1;
  $GLOBALS['TSFE']-&gt;fe_user-&gt;createUserSession($user);
  $GLOBALS['TSFE']-&gt;fe_user-&gt;setAndSaveSessionData('user', TRUE);
  
  return json_encode(['login' =&gt; 'true']);
  </code></pre>
  
  <p>when trying to print out <code>$GLOBALS['TSFE']-&gt;fe_user</code> before the return, the data are set and <code>$GLOBALS['TSFE']-&gt;loginUser = 1</code> , so everything looks file. When I reload the login form afterwards though, the fe_user data are still there, but the fluid <code>security.ifAuthenticated</code> does not work. </p>
  
  <p>The Form view looks like this: </p>
  
  <pre><code>&lt;f:security.ifAuthenticated&gt;
      &lt;f:then&gt;
          user is authenticated!
      &lt;/f:then&gt;
      &lt;f:else&gt;
          &lt;f:render partial="LoginForm.html"/&gt;
      &lt;/f:else&gt;
  &lt;/f:security.ifAuthenticated&gt;
  
  Username: {user.firstName}
  </code></pre>
  
  <p>And it corretly outputs the Firstname of the logged in user, but also still shows the loginform. <code>security.ifAuthenticated</code> always enters the ELSE. And when I looked at the viewHelper it is because <code>$GLOBALS['TSFE']-&gt;loginUser</code> is not set. </p>
  
  <p>Any hints/ideas as to why this is happening? </p>