Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trackers Session : user_id is null #485

Open
piep14 opened this issue Jan 27, 2020 · 12 comments
Open

Trackers Session : user_id is null #485

piep14 opened this issue Jan 27, 2020 · 12 comments

Comments

@piep14
Copy link

piep14 commented Jan 27, 2020

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.

@piep14
Copy link
Author

piep14 commented Feb 6, 2020

@antonioribeiro ^^

@kazemimorteza68
Copy link

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.

@kazemimorteza68
Copy link

#479

@piep14
Copy link
Author

piep14 commented Feb 17, 2020

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?

@piep14
Copy link
Author

piep14 commented Feb 28, 2020

@kazemimorteza68 @antonioribeiro

Can you help me ?

@hopingsteam
Copy link

I have the same error! Configured everything properly but still doesn't work.
Using Laravel 6.18

@HamidNiakan
Copy link

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.

@calazcano
Copy link

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();
}

@stephenmudere
Copy link

stephenmudere commented Apr 9, 2020

I figured this out after following through the code. There are three crucial steps that must be followed .

  1. 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
  2. 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

@vinkev
Copy link
Contributor

vinkev commented Sep 23, 2020

I made a PR to solve this issue

#514

@suntaehong
Copy link

calazcano commented on 9 Apr 2020 -> Excellent!! It's working fine.

@saqlain-syed
Copy link

$visitor = \Tracker::currentSession();

it works, Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants