[Vuejs]-Lumen 5.5 Session store not set on request

0πŸ‘

βœ…

I think you just misunderstood the concept of Web Service (API). API is not a stateful application, rather it’s a stateless, means no session available for each request. So, in major API framework, session is not supported (officially). To handle your problem, you can store your temporary credentials in a database or maybe in a cache (with TTL, eg: 60 minutes), like this:

$requestIdentifier = $request->getClientIdentifier(); // YOU SHOULD IMPLEMENT THIS METHOD

Cache::put($requestIdentifier, $temporaryCredentials, 60);

To retrieve your cache just use:

$temporaryCredentials = Cache::get($requestIdentifier);

Here I give you some idea, when you implement getClientIdentifier, you can force the client to send a unique key inside your header, like:

axios.post('http://somewhere', {
    headers: {
        'x-request-identifier': UNIQUE_ID
    }
})

In your API:

$requestIdentifier = $request->header('x-request-identifier');

Leave a comment