Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cartalyst Sentinel check() always returns false in Laravel 5.2

I use Cartalyst Sentinel to authenticate user

$status=Sentinel::authenticate($credentials);

the above code is in the login function in UserController. In the login function I can see that the Sentinel::check() returns some data. However, after login and redirecting the another page in the AccountController, the Sentinel::check() always returns false despite the user has logged in and not yet trigged the logout button.

Anyone knows how to solve this problem ?

like image 219
Priska Aprilia Avatar asked Jan 21 '26 21:01

Priska Aprilia


1 Answers

You'll need to verify that you are setting the user to remember.

Sentinel::authenticateAndRemember($credentials)

Just authenticating doesn't set the user in the session. If that doesn't fix your problem you should verify the Facade you're using. Sentinel comes packaged with two facades, both a Laravel and Native facade. If you're using Laravel and call the Native Facade you will get a false return. The inverse does the same.

Hope that helps.

like image 57
atxpunkrock Avatar answered Jan 24 '26 23:01

atxpunkrock



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!