API does not support sessions. how can I use the session in API?

Viewed 31

I am working on laravel eCommerce API. API does not support sessions. how can I develop cart functionality without storing cart items in the database?

1 Answers

By default, you can't use sessions in api because larval won't initiate sessions in case of api. look at kernel.php.

You can add middleware "web" to your route or add \Illuminate\Session\Middleware\StartSession::class, to middleware api anyway. But try to avoid it (personal opinion).

Related