您好我有一个typo3扩展程序,用于在会话中存储数据。
我的操作完成后,我想删除会话数据。
我试过了:
$GLOBALS['TSFE']->fe_user->removeSessionData();
但这不起作用。
我的失败是什么?提前致谢
更新
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
));
答案 0 :(得分:3)
如果您执行了$GLOBALS['TSFE']->fe_user->setAndSaveSessionData('session_key', $somevalue);
,只需执行$GLOBALS['TSFE']->fe_user->setAndSaveSessionData('session_key', null);
即可删除会话数据。