I want to detect (track) when user logs-in using "remember me" option (via cookie/session). I have app/Listeners/UserEventSubscriber.php:
<?php
namespace App\Listeners;
class UserEventSubscriber
{
public function onUserLogin($event)
{
\Log::info('logged-in'); // NEVER WORKS IF IT WAS "VIA REMEMBER"... BUT WORKS WHEN USER LOGS-IN REGULARLY (USING LOGIN-FORM)
}
public function subscribe($events)
{
$events->listen(
'Illuminate\Auth\Events\Login',
'App\Listeners\UserEventSubscriber@onUserLogin'
);
}
}
... and, of course, this was registered in app/Providers/EventServiceProvider.php:
protected $subscribe = [
'App\Listeners\UserEventSubscriber'
];
This detects only the "regular" log-ins (via login-form). But it doesn't detect the "via remember" login. For example:
- I check the "remember me" option and login;
- I close the browser;
- I open the browser and visit the site - and I'm logged in;
... but that wasn't detected.
I'm using Laravel 5.5 (LTS). Session configuration is the default one (which comes with the fresh installation of Laravel), except: SESSION_DRIVER=database.
Is this some issue/bug with Laravel (5.5)? Or maybe I'm doing something wrong (if so, what would be the correct way to detect "via remember me" log-ins?)?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire