Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

MellisaS's avatar

User session in API response

Hello,

I have a request where I need to refactor existing laravel app, to use ajax/api instead of classic web-routes. API is implemented with JWT token auth. The problem is that frontend is done with blade templates that relies a lot on (Auth::check()) function. And in login with API laravel_session cookie with auth user is not set and the view is not responding properly. Is it possible to return session for the user in API and store it manually in a cookie? Or there is a better approach to solve this?

Thanks,

0 likes
3 replies
ronon's avatar

You can use Auth::check on the API side as well.

MellisaS's avatar

And problem is with ex. guarded routes, with this kind of auth, laravel's isAuth doesn't work...

ronon's avatar

If you use any kind of authenthication, you are authenticated. So you even don't need to use Auth::check

Please or to participate in this conversation.