Back

Auth::check always returning false


gwinans posted 4 years ago

I can't figure this out for the life of me.

The Laravel docs imply/state that Auth::check should return true if a user is logged in (via Auth::attempt). For me, Auth::check() always returns false -- this is regardless of what I use to store session data. I've tried the default, in the database and memcached (verified that data was being written).

The Domain value in the sessions config file is correct (i've tried both permutations -- itops-apps.internal.local, itops-apps).

Here's a relevant gist:

https://gist.github.com/gwinans/098e845fc5a643e7dd34

Everything works except for Auth::check(). I've verified, at least, that session data persists across page loads.

Please be aware I'm still in the early learning stages with laravel.

rickshawhobo replied 4 years ago

Here's one thing. Anytime you work with sessions make sure you're not echoing things before putting things into the session. Any output before the session header will invalidate it. I would set some variables and return a proper view if you want to debug.

gwinans replied 4 years ago

I've since moved all the output to the .blade.php views.

The issue remains.

In fact, if I stick dd(Auth::check()) into a view, the view stops rendering where that call appears. There is no error in the apache logs nor in the laravel.log

gwinans replied 4 years ago Solution

For the moment, I've fixed this by setting the domain value in config/sessions.php to null. I'm at a loss as to why the value doesn't function with their of the valid hostnames.

theInvisibleMan replied 3 years ago

Did you ever find out what was wrong?


Sign in to participate in this thread!



We'd like to thank these amazing companies for supporting us