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

Devmaurice's avatar

Cart Session in a Stateless environment

So i have this app , an api serving mobile backed. I have implemented authentication and all that. Now i want to work on a cart. On my localhost using Postman,it's working very well.

The problem is when tunnel through ngrok for the mobile guys to test. The cart does not persist.

Am aware of the stateless situation i just don't know how i should go about this to create a cart to serve the mobile app.

Should the mobile app maintain the cart?

If it's laravel just a tip how i should go about it?

0 likes
4 replies
martinbean's avatar

@Devmaurice You could either retrieve the cart based on the user’s ID (as I’m assuming the mobile apps send a token that’s related to a user) or when the cart is created, the client app saves that cart’s unique identifier and then makes any subsequent requests (i.e. adding a product, removing a product) against that ID.

Devmaurice's avatar

@martinbean I had implemented this cart

Now the problem is the cart works with sessions but do database or file driver. Is there a way or cart i can use this using file or database to serve stateless environment.

Please or to participate in this conversation.