8000 [5.1] Concurrent requests wiping out the session · Issue #14385 · laravel/framework · GitHub
[go: up one dir, main page]

Skip to content

[5.1] Concurrent requests wiping out the session #14385

New issue

Have a question 8000 about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
vikasddun opened this issue Jul 20, 2016 · 8 comments
Closed

[5.1] Concurrent requests wiping out the session #14385

vikasddun opened this issue Jul 20, 2016 · 8 comments

Comments

@vikasddun
Copy link

We are using Laravel( framework version - 5.1.37) to create REST APIs which are then consumed by a NodeJS server. We are using file driver for session storage. On some of the pages, we need to make 5-6 API requests almost simultaneously, all of which are read requests not making any write on session. Most of the times, this cause the removal of session and hence user gets logged out.

I have seen the similar problems mentioned in #7549 #5416 , but haven't found any solution yet. Any suggestions ?

@vikasddun vikasddun changed the title 5.1 - Concurrent requests wiping out the session [5.1] Concurrent requests wiping out the session Jul 20, 2016
@rreynier
Copy link

Though this likely should be fixed, I suggest using Redis or Memcache driver if possible. As mentioned in other issues, there may be some file corruption going on when 4-5 things are trying to read/write the same file on the disk.

@GrahamCampbell
Copy link
Member

The only true way to fix this is to not allow concurrent requests, since how do you know which request actually has the session data you want. A way to achieve this could be by making yourself a locking middleware. I've implemented on that only uses redis as a lock server.

@GrahamCampbell
Copy link
Member

@GrahamCampbell
Copy link
Member

It only locks for "non-safe" requests, but could be modified to lock all requests per IP.

@Bonobomagno
Copy link

What about a delay? Something like occ?

@denjaland
Copy link
Contributor

Sorry about not noticing this issue earlier - @GrahamCampbell could you perhaps have a look at my description for #18187? This issue was referenced, but I'm thinking the issue is q bit different.
I think my proposed solution does in fact fix (part) of the problems in the various use cases I've noticed.

Thanks!

@dsandber
Copy link

Am I correct that this issue (multiple concurrent requests will overwrite the session and thus cause token mismatches or unauthorized access errors) still exists in Laravel 5.7? And that using Redis or Cookies for session storage won't help since the session will still be non-atomically updated on requests?

@denjaland
Copy link
Contributor

I don’t think it’ll be solved quickly. Avoid using sessions in laravel; I’ve moved towards an entirely stateless setup disconnectibg my frontend from the backend entirely, and consuming the backend api’s from my vue app using token bsed authentication. Laravel passport does work quite well for that purpose as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants
0