问题
Hi I have an typo3 extension that stores data in session.
After my actions are finished I want to remove the session data.
I tried this:
$GLOBALS['TSFE']->fe_user->removeSessionData();
But this does not work.
What is my fail? Thanks in advance
UPDATE
if ( is_null($GLOBALS["TSFE"]->fe_user->getKey("ses", "Step1")) ) {
$this->redirect('noProductFound');
}
$arguments = $this->request->getArguments();
$reloadPage = new \TYPO3\ShopExtension\Controller\ShopStep();
$product = $arguments['product'];
$orderProcessed = $GLOBALS['TSFE']->fe_user->getKey('ses', 'orderProcessed');
#Verhindern das Seite neu geladen wird und eine neue Bestellung getätigt wird.
if ($reloadPage->getReload() == true | $orderProcessed == true) {
$this->redirect('noProductFound', null, null, array('error' => 'orderProcessed'));
} else {
if ($product == ShopConstant::AG_TRIAL) {
$this->save_Product_Trial();
$reloadPage->setReload(true);
$GLOBALS['TSFE']->fe_user->setKey('ses', 'orderProcessed', true);
$GLOBALS['TSFE']->storeSessionData();
} elseif ($product == ShopConstant::AG_PROFESSIONELL || $product == ShopConstant::AG_PREMIUM || $product == ShopConstant::AG_ULTIMATE) {
$afterOrderOrderId = $this->save_Product_Auditgarant($product);
$reloadPage->setReload(true);
$GLOBALS['TSFE']->fe_user->setKey('ses', 'orderProcessed', true);
$GLOBALS['TSFE']->storeSessionData();
} elseif ($product == ShopConstant::BOOK_AL || $product == ShopConstant::BOOK_PH || $product == ShopConstant::BOOK_CPMS || $product == ShopConstant::BOOK_USABILITY) {
$this->save_Product_Book($product);
$reloadPage->setReload(true);
$GLOBALS['TSFE']->fe_user->setKey('ses', 'orderProcessed', true);
$GLOBALS['TSFE']->storeSessionData();
} elseif ($product == ShopConstant::INSTITUTSTAG || $product == ShopConstant::INSTITUTSTAG_PARTNER || $product == ShopConstant::INSTITUTSTAG_ALUMNI) {
$this->save_Product_Institutstag($product);
$reloadPage->setReload(true);
$GLOBALS['TSFE']->fe_user->setKey('ses', 'orderProcessed', true);
$GLOBALS['TSFE']->storeSessionData();
} else {
$this->redirect('noProductFound');
}
#Session löschen, da Daten ab hier nicht mehr benötigt werden.
$GLOBALS['TSFE']->fe_user->removeSessionData();
$GLOBALS['TSFE']->fe_user->setKey('ses', 'Step1', null);
$GLOBALS['TSFE']->storeSessionData();
// \TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($GLOBALS['TSFE']);
// exit();
#Führt einen redirect durch mit angehängtem Attribut des letzten Step.
$this->redirect('getContent', null, null, array(
'step' => $arguments['lastStep'],
'shopStep' => $arguments['product'],
'afterOrderOrderId' => $afterOrderOrderId
));
回答1:
In case you did $GLOBALS['TSFE']->fe_user->setAndSaveSessionData('session_key', $somevalue);
you can simply do $GLOBALS['TSFE']->fe_user->setAndSaveSessionData('session_key', null);
to delete the session data.
来源:https://stackoverflow.com/questions/49445116/typo3-remove-session-data-of-fe-user