Skip to content

Instantly share code, notes, and snippets.

@checkerap
Created March 2, 2016 10:53
Show Gist options
  • Save checkerap/2ea051a027cfa1b4aa09 to your computer and use it in GitHub Desktop.
Save checkerap/2ea051a027cfa1b4aa09 to your computer and use it in GitHub Desktop.
Login a user in a typo3 extenbase extension
<?php
// now login the user
$fe_user = $GLOBALS['TSFE']->fe_user;
$fe_user->createUserSession(array('uid' => $uid));
$fe_user->user = $fe_user->getRawUserByUid($uid);
$fe_user->fetchGroupData();
$GLOBALS['TSFE']->loginUser = 1;
// set the cookie
$reflection = new \ReflectionClass($GLOBALS['TSFE']->fe_user);
$setSessionCookieMethod = $reflection->getMethod('setSessionCookie');
$setSessionCookieMethod->setAccessible(TRUE);
$setSessionCookieMethod->invoke($GLOBALS['TSFE']->fe_user);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment