In my Extbase extension, I wrote my own login mechanism, that triggers a manual login as a fe_user like this:
$GLOBALS['TSFE']->fe_user->checkPid = 0;
$info = $GLOBALS['TSFE']->fe_user->getAuthInfoArray();
$user = $GLOBALS['TSFE']->fe_user->fetchUserRecord($info['db_user'], $feUsername);
$GLOBALS['TSFE']->fe_user->createUserSession($user);
$GLOBALS['TSFE']->fe_user->setAndSaveSessionData('dummy', TRUE);
$GLOBALS['TSFE']->loginUser = 1;
this->redirect(null, null, null, null, 38);
Afterwards I redirect the user to a page (ID 38) that has its Usergroup Access Rights set in a way, so that only this fe_user can access the page.
The login works and after login I can see the protected page in the menu and can access it. However, the redirect to the protected page doesn’t work. I end up on the home page. It seems the the login is somehow not fully active at the time when the redirect is taking place, but only after the page has been fully loaded once.
Any idea how to fully apply the login prior to redirect?