0

I am having an issue with accessing the authenticated user data once registered on the system.

After carrying out some validation within my Registration process I have this line:

if (Auth::attempt(array(
        'username' => $customer->username,
        'password' => $data['password']
    ))) {
        return redirect('profile-setup');
    }

I have tried die to see the user data within this if statement, like this:

dd(Auth::user());

This actually works and I can see the user data.

However When I go to the blade profile-setup, I tried the same die but I am getting a null value.

I am not sure as to what I have missed out.

If there's anything that needs to be provided from my end please just let me know. Any help with be appreciated.

Thanks

dark_illusion_909099
  • 1,067
  • 2
  • 21
  • 41

1 Answers1

1

You can see if any of this is present in your case :

  • Specifying protected $primaryKey = 'user__table_id_column_name'; in user model
  • If you see the method signature inside the larvel's core you will see :

public function attempt(array $credentials = [], $remember = false, $login = true){ .. }

So try passing second argument to attempt as true and see if it persists. This should not be the case as this should happen automatically but try once for safe fide

  • Remove echo statements if you have any for debugging
  • Check if you are calling Auth::logout() anywhere by mistake before the last dd
  • try redirect()->intended('profile-setup');

For more help follow just check thread : Laravel Auth:attempt() will not persist login

Mihir Bhende
  • 8,677
  • 1
  • 30
  • 37