Session data lost after autologin
I have the same problem like @Skiud.
On my website is a shop where users can add products to the basket without logged in. After registration and autologin the basket is empty.
The problem seems to be in UserUtility->login().

The following line overrides the ses_data where the basket content is stored.
$tsfe->fe_user->user = $tsfe->fe_user->fetchUserSession();
Here you see the state before autologin.

And here the state after autologin.

Do you have a solution how to fix it?
Originally posted by @nollm in https://github.com/in2code-de/femanager/issues/57#issuecomment-607159464
@nollm Is there a fix for that? How did you solve the problem? Have the same problem.After autologin the tx cart session data gets lost.
@kevinlieser Sorry for the late answer. Usually it is a bad idea but I commented out this line //$tsfe->fe_user->user = $tsfe->fe_user->fetchUserSession();.
I fixed that for me with this XClass (hope that was all I have done. It saves the oldSession data and restores it in a foreach loop at the end.
class CustomUserUtility extends In2code\Femanager\Utility\UserUtility
{
public static function login(User $user, $storagePids = null)
{
$tsfe = self::getTypoScriptFrontendController();
$oldSessionData = $tsfe->fe_user->getAllSessionData();
$tsfe->fe_user->checkPid = false;
$info = $tsfe->fe_user->getAuthInfoArray();
$cleanIntList = implode(',', GeneralUtility::intExplode(',', $storagePids));
$extraWhere = ' AND uid = ' . (int)$user->getUid();
if (!empty($storagePids)) {
$extraWhere = ' AND pid IN (' . $cleanIntList . ')';
}
$user = $tsfe->fe_user->fetchUserRecord($info['db_user'], $user->getUsername(), $extraWhere);
$tsfe->fe_user->createUserSession($user);
self::loginAlternative($tsfe);
$tsfe->fe_user->user = $tsfe->fe_user->fetchUserSession();
$tsfe->fe_user->setAndSaveSessionData('ses', true);
foreach($oldSessionData as $index => $value) {
$tsfe->fe_user->setAndSaveSessionData($index, $value);
}
}
}