1

I using Sentinel package, Everything is fine, But when I want call Sentinel::check() and Sentinel::getUser() using ajax, it return null. help me please :(

$currentUser = Sentinel::getUser();
$my_id = $currentUser->id;
return $my_id;
Hossein Bajan
  • 2,644
  • 5
  • 19
  • 36

1 Answers1

0

I used another way. First add user's info into a session after logging

Session::put('city_id', $currentUser->city_id);

then goto app/Http/Kernel.php and active session on rest api routes

'api' => [ \App\Http\Middleware\EncryptCookies::class, \Illuminate\Session\Middleware\StartSession::class, 'throttle:60,1', 'bindings', ],

and use it in ajax call.

Hossein Bajan
  • 2,644
  • 5
  • 19
  • 36