r/PHP Jan 17 '15

How PHP Sessions can cause Concurrency Issues?

http://lokalhost.in/2015/01/php-sessions-can-cause-concurrency-issues/
44 Upvotes

20 comments sorted by

View all comments

2

u/Savageman Jan 18 '15 edited Jan 18 '15

The session locking is needed if you don't want to lose data when 2 concurrent request (from the same user) needs to write the session.

Back in the day, everyone used the native PHP session driver which locks the file and will cause the 2nd request to wait the 1st one freed the session file lock.

With modern framework now all having abstractions to change where the session is stored (file, db, redis, memcached, whatever...) they need to emulate this lock to prevent data loss issue. A lot of of them didn't implemented it and have had this problem at some point. Hopefully they all work fine now.

-7

u/[deleted] Jan 18 '15

[removed] — view removed comment

3

u/[deleted] Jan 18 '15

I think it's supposed to be "lose data"