samedi 26 septembre 2020

Laravel 5.5.50 - Session doesn't persist for api. Interestingly it works with postman but not with our Shopify store that sends the API request

Our Shopify store talks to our laravel app by sending an API call. I need to cache a value on the server to improve the loading speed for the next API request. I have tried almost all solutions mentioned in stackoverflow and other places, but non of the worked for me!

Interestingly, when I test it using postman it works fine (in both my local and staging) and the session persists, but when Shopify sends the API request, the session doesn't persists and returns null! (when the client enters a postcode in a form in Shopify, and submits it, the request is sent to the laravel app). I also cleared the cache but didn't work (php artisan cache:clear, config:clear, config:cache, route:clear)

I have no idea whether I am missing something or it is bug for laravel. Please see my code bellow. I highly appreciate your help. Also please let me know about any other alternative way?

app/Services/abc.php

Use Illuminate\Support\Facades\Session;
...

    public function resolve(Address $shippingAddress, Collection $lineItems) : Collection
    {
        ...
        Session::put($sessionShippingAddress, $shippingAddress);
        Session::save();
        ...
    }
...

Kernel.php

    protected $middleware = [
        ...
        \Illuminate\Session\Middleware\StartSession::class
    ];

Routes/api.php

...
Route::post('abc', 'abcController@calculateSimple');
...

session.php

...
    'lifetime' => env('SESSION_LIFETIME', 5),
    'expire_on_close' => false,
...


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3idP6D6
via IFTTT

Aucun commentaire:

Enregistrer un commentaire