Skip to content
Advertisement

Laravel Auth::user() always null

I have created this login function it returns login success when entering the correct user name and password

JavaScript

I have to define route like this in route/api.php

JavaScript

but when I call Auth::user() in another controller or another view it returns null what is wrong with it

Advertisement

Answer

I have fixed this error. I have created an authentication route in route/api.php. API route not supported to the session so it does not store user data in the session because that Auth::user() always returns null. please view this answer https://stackoverflow.com/a/44863089/13729121

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement