The PSR-14 event \TYPO3\CMS\FrontendLogin\Event\LogoutConfirmedEvent is triggered when a logout was successful.

Example: Delete stored private key from disk on logout

Upon logout a private key the user uploaded for decryption of private information should be deleted at once. There is only a logout event if the user actively clicks the logout button, so if the user would just close the browser window there would be no LogoutConfirmedEvent. For this case we need a second line of defense like a scheduler task (out of scope of this example).

The currently logged-in user derived from the \TYPO3\CMS\Core\Context\Context is now an anonymous user that is not logged in. The information on which user just logged out cannot be determined from the context or the methods from the event. We therefore need different logic to determine the user who just logged out. This logic is not part of the example below.



namespace MyVendor\MyExtension\EventListener;

use MyVendor\MyExtension\KeyPairHandling\KeyFileService;
use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Context\UserAspect;
use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity;
use TYPO3\CMS\FrontendLogin\Event\LogoutConfirmedEvent;

    identifier: 'my-extension/delete-private-key-on-logout',
final readonly class LogoutEventListener
    public function __construct(
        private KeyFileService $keyFileService,
        private Context $context,
    ) {}

    public function __invoke(LogoutConfirmedEvent $event): void
        $userAspect = $this->context->getAspect('frontend.user');
        assert($userAspect instanceof UserAspect);
        if ($this->keyFileService->deletePrivateKey($userAspect)) {
            $event->getController()->addFlashMessage('Your private key has been deleted. ', '', ContextualFeedbackSeverity::NOTICE);
        } else {
            $event->getController()->addFlashMessage('Deletion of your private key failed. It will be deleted automatically within 15 minutes by a scheduler task. ', '', ContextualFeedbackSeverity::WARNING);

New in version 13.0

The PHP attribute \TYPO3\CMS\Core\Attribute\AsEventListener has been introduced to tag a PHP class as an event listener. Alternatively, or if you need to be compatible with older TYPO3 versions, you can also register an event listener via the Configuration/Services.yaml file. Switch to an older version of this page for an example or have a look at the section Implementing an event listener in your extension.


class LogoutConfirmedEvent
Fully qualified name

A notification when a log out has successfully arrived at the plugin, via the view and the controller, multiple information can be overridden in Event Listeners.

getController ( )
getView ( )