How to hook logout action for frontend user in Typo3 v8 or v9

Viewed 383

I am developing a Typo3 extension and I want to hook logout action of frontend user. I searched for a proper guide/tutorial and got a rough idea how can w dok that. I tried two methods:

1) Using Logout_confirmed Hook but it didn't work. Maybe I am missing something. What I did is... I mentioned below line in ext_localconf.php

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['felogin']['logout_confirmed'] = Vendor/Ext_key/Hooks/Logout::class.'->checklogout'

and created a class at the given path Vendor/Ext_key/Hooks/Logout::class.'->checklogout'... But the flow never reaches the checklogout() method, when user hits logout. Can somebody tell what am I missing or doing wrong.

2) I tried intercepting logout request directly in a controller action by checking

            if ($_REQUEST['logintype'] == 'logout')

I can intercept this request but the user gets logged out and its data is cleared from the session before I intercept it in Controller. I have to set some values per user basis when a user hits logout, so I want to hook in between user hits logout and before his session is cleared. So that I can access username and set values for that user accordingly.

0 Answers
Related