{"action":"created","issue":{"url":"https://api.github.com/repos/laravel/framework/issues/7549","labels_url":"https://api.github.com/repos/laravel/framework/issues/7549/labels{/name}","comments_url":"https://api.github.com/repos/laravel/framework/issues/7549/comments","events_url":"https://api.github.com/repos/laravel/framework/issues/7549/events","html_url":"https://github.com/laravel/framework/issues/7549","id":58467375,"number":7549,"title":"Laravel 5.0 - Asyncronous AJAX Requests cause Session Variable Changes to be Overwritten","user":{"login":"loren138","id":1224505,"avatar_url":"https://avatars.githubusercontent.com/u/1224505?v=3","gravatar_id":"","url":"https://api.github.com/users/loren138","html_url":"https://github.com/loren138","followers_url":"https://api.github.com/users/loren138/followers","following_url":"https://api.github.com/users/loren138/following{/other_user}","gists_url":"https://api.github.com/users/loren138/gists{/gist_id}","starred_url":"https://api.github.com/users/loren138/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/loren138/subscriptions","organizations_url":"https://api.github.com/users/loren138/orgs","repos_url":"https://api.github.com/users/loren138/repos","events_url":"https://api.github.com/users/loren138/events{/privacy}","received_events_url":"https://api.github.com/users/loren138/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-02-21T17:40:10Z","updated_at":"2015-05-29T13:35:13Z","closed_at":"2015-02-21T17:54:29Z","body":"If a number of AJAX requests are fired which get processed simultaneously by the webserver, the session files do not lock causing session variables to be overwritten.\r\n\r\nOn rare occasions, the session file can become corrupted if one copy reads in a half written out file.  This condition, however, is difficult to reproduces.\r\n\r\nPractically, you probably shouldn't be firing a number of AJAX requests simultaneously, but it is always possible that a user quickly clicks on several buttons that result in requests and the server happens to process those requests simultaneously which would be a reasonable design and result in session problems.\r\n\r\nI've put together I very simple demo of this using 26 variables (a-z) which are each incremented by a separate AJAX request.  The final result isn't that all 26 variables have the value of 1 (which it should be).\r\n\r\nhttps://github.com/wiseloren/laravel-race\r\n\r\nI think this is referenced in #4441 #4576 #4400  I think in these issues the problem is in file corruption due to reads and writes happening at the same time to the session file, which as I mentioned above, I can't reliably reproduce (though I do think it happened at least once during my testing because half my variables disappeared).\r\n\r\nThough it is outdated now #6848 seems to have been intended to fix this.  If someone can verify this, I'm willing to work on updating the pull request and try to get the style in line which seems to have been the only previous complaint.  I'm not sure how one would write a unit test for this since unit tests are executed synchronously and this only happens in async execution."},"comment":{"url":"https://api.github.com/repos/laravel/framework/issues/comments/106803830","html_url":"https://github.com/laravel/framework/issues/7549#issuecomment-106803830","issue_url":"https://api.github.com/repos/laravel/framework/issues/7549","id":106803830,"user":{"login":"taisph","id":814148,"avatar_url":"https://avatars.githubusercontent.com/u/814148?v=3","gravatar_id":"","url":"https://api.github.com/users/taisph","html_url":"https://github.com/taisph","followers_url":"https://api.github.com/users/taisph/followers","following_url":"https://api.github.com/users/taisph/following{/other_user}","gists_url":"https://api.github.com/users/taisph/gists{/gist_id}","starred_url":"https://api.github.com/users/taisph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/taisph/subscriptions","organizations_url":"https://api.github.com/users/taisph/orgs","repos_url":"https://api.github.com/users/taisph/repos","events_url":"https://api.github.com/users/taisph/events{/privacy}","received_events_url":"https://api.github.com/users/taisph/received_events","type":"User","site_admin":false},"created_at":"2015-05-29T13:35:13Z","updated_at":"2015-05-29T13:35:13Z","body":"I'm getting this problem with all tested drivers (native, file, memcached and redis) in Laravel 4.2.\r\n\r\nImagine a browser making multiple (ajax) requests with the same session id:\r\nRequest 1: Enters, loads session, does some heavy database processing.\r\nRequest 2: Enters, loads session, changes a session var, stores the session, returns a result.\r\nRequest 1: Finishes processing, stores previously loaded session, returns result.\r\nSession changes in request 2 are effectively overwritten by request 1.\r\n"}}