我有typo3 9.5。
如何以typo3方式登录后端用户?
我尝试过
$GLOBALS['BE_USER'] = GeneralUtility::makeInstance('TYPO3\CMS\Core\Authentication\BackendUserAuthentication');
$GLOBALS['BE_USER']->user['uid']=2;
$GLOBALS['BE_USER']->start();
但这不起作用。
答案 0 :(得分:0)
我找到了解决方法:
$GLOBALS['BE_USER'] = GeneralUtility::makeInstance('TYPO3\CMS\Core\Authentication\BackendUserAuthentication');
$GLOBALS['BE_USER']->start();
$GLOBALS['BE_USER']->setBeUserByUid(2);
$GLOBALS['BE_USER']->createUserSession($GLOBALS['BE_USER']->user);
$url = GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir;
\TYPO3\CMS\Core\Utility\HttpUtility::redirect($url);