Laravel 5 Asynchronous AJAX requests cause session problems

I am using Laravel 5 (version laravel / framework "v5.1.16", Homestead Ubuntu), with session = 'file' driver.

I noticed that if multiple asynchronous AJAX requests (jQuery) are being executed, for example. in the autocomplete form field, then the session variables disappeared.

This only happens with async AJAX requests, when the async option is set to false, this problem no longer exists.

Also, when the session driver is set to cookie and async is set to true, a new cookie is created in each AJAX request, so 10 larvel files, etc., will be created with 10 requests.

Any suggestions? I was not able to find any decent reason or solution for this, except for using asynchronous requests.

Related issues that appear to be fixed.

https://github.com/laravel/framework/issues/7549

https://github.com/laravel/framework/issues/5416

+5
source share
2 answers

For the sake of answering this question and how "The Shift Exchange" is already explained in his comment ...

This is a known issue - without a solution: github.com/laravel/framework/issues/8172 - the problem is that no one can provide a replicated situation - it seems random, rare, and for no apparent reason.

+1
source

I recently ran into this problem, and the problem may have been double linking web middleware on the route. You have to check it out. I did not notice that the network was already applied in RouteServiceProvider . After removing 'middleware' => 'web' on my problematic routes, this problem completely disappeared.

0
source

Source: https://habr.com/ru/post/1232462/


All Articles