I am trying to execute some code when a user logs out when a session lifetime ends. But it doesn't seem to log out via the usual Logout
event. Because I have the following event:
namespace App\Listeners;
use Illuminate\Support\Facades\Log;
use Illuminate\Auth\Events\Logout;
class UserLoggedOut
{
public function handle(Logout $event)
{
Log::debug("User logged out");
}
}
and I registered it in EventServiceProvider
:
protected $listen = [
'Illuminate\Auth\Events\Logout' => [
'App\Listeners\UserLoggedOut',
],
];
The code works when a user logs out via the logout button and I see the message in the logs. However when the session lifetime ends and the user disconnects, it does not trigger this Lougout
event.
Is there a way to make it work?