Typo3 Extbase losing fe_user authentication

2019-08-23 05:49发布

I have this little snippet for logging in a user with my own Typo3 extension:

$GLOBALS['TSFE']->fe_user->createUserSession(array());
$GLOBALS['TSFE']->fe_user->user = $GLOBALS['TSFE']->fe_user->getRawUserByUid($this->userRepository->findByUsername($winAcc)->toArray()[0]->getUid());
$GLOBALS['TSFE']->fe_user->fetchGroupData();
$GLOBALS['TSFE']->loginUser = 1;

In the fluid template I can check if a user is logged in with this:

<f:security.ifAuthenticated>
  This is being shown whenever a FE user is logged in
</f:security.ifAuthenticated>

However this code works only for the next action which is executed in the controller. When the FrontEnd User reloads the page, the authentication is lost and also $GLOBALS["TSFE"]->loginUser is null.

Why is this happening?

1条回答
家丑人穷心不美
2楼-- · 2019-08-23 06:47

Okey, I have the solution for this problem. In Typo3 6.2 LTS there seems to be a different cookie handling. The cookie fe_user cookie is not being set. Use any method of TSFE to force typo3 to set this cookie.

查看更多
登录 后发表回答