tracker
tracker copied to clipboard
Trackers Session : user_id is null
Hello,
I am under Laravel 6 and since the last update of the Package, in "tracker_sessions", the value of "user_id" is always null.
Would it be possible to correct this bug?
Thank you in advance.
@antonioribeiro ^^
Hi. Vendor/Laravel/ServiceProvider.php
` public function boot() { parent::boot();
if (!$this->getConfig('enabled')) {
return false;
}
$this->loadRoutes();
$this->registerErrorHandler();
// $this->bootTracker();
$this->loadTranslations();
}`
You can just comment this line out ($this->bootTracker();) in the package Service Provider boot method.
https://github.com/antonioribeiro/tracker/issues/479
I edited the package directly in the FTP, then commented the line as you suggest. But it still doesn't work. Are there a few more things to do?
@kazemimorteza68 @antonioribeiro
Can you help me ?
I have the same error! Configured everything properly but still doesn't work. Using Laravel 6.18
I have a problem when the user login at the website, and doesn't save user-id at the table tracker_sessions. it is always null. please help me and give me a solution.
My solution was in the Login controller: It's not cute but it works hahaha.
$visitor = \Tracker::currentSession(); if($visitor) { $visitor->user_id= Auth::user()->id; $visitor->save(); }
I figured this out after following through the code. There are three crucial steps that must be followed .
- ensure that the correct auth guard is set in config/auth.php this usually is set to web and the provider model is App\User::class in fresh installations . If your application is using a different auth gaurd and path for model it may work fine but missing user_id on saved data in this package may be sign of a miss-configured auth guard
- With this done now you need to set the guard in (1 ) in config/tracker.php on the authentication_guards key for example
'authentication_guards' => ['web']
3) in Vendor/Laravel/ServiceProvider.php
comment out
$this->bootTracker();
If this is done the package should now pick up the user_id
calazcano commented on 9 Apr 2020 -> Excellent!! It's working fine.
$visitor = \Tracker::currentSession();
it works, Thanks