@princeparaste APIs are stateless. You don’t use sessions.
It completely defeats the point of using token-based authentication like OAuth (which is what Passport is) if you then just save that token in a session.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am using LARAVEL Passport for building Rest API's.
I saved the user auth token in Laravel Session during the login time. I am using payment gateway. When user make payment i redirect my website to the payment gateway website. and on success response i redirect back to my laravel website.
The problem is when i do this for the 1st time on a day it always gives me Unauthenticated Error on 1st try. On the 2nd,3rd try and so on it works fine.
It only gives me this error on 1st try of the day.
I try to debug it and find out that the Session::get('token'); is always getting empty on the 1st try.
So in the backend API, it checks wheather the user has token or not. on 1st try its always empty so it gives Unauthenticated Error
I dont know why this happening on every 1st try only. Any ideas why is this ?
Please or to participate in this conversation.