Codeigniter session bugging out with ajax calls

My CodeIgniter app uses the session library and saves data to the DB. I've been having some problems where blank sessions are created after a certain ajax call. Upon investigating, it seems that there were 2 simultaneous functions calls that fired off that require a session validation. One would fail and the other would be fine. I was able to fix this by not having them fire off simultaneously. But I still don't understand the REASON why it fails. Does it have to do with one call updating the user cookie and the 2nd call invalidating? Or maybe when reading the DB it dies somehow? I looked over the Session core class a bit and have not found any clues to the cause. If any one had the same problem before I would appreciate any advice on how to debug or what the cause is. Thanks! EDIT: I originally said there was a 408 status return. That was an unrelated case. This is the function that fires off MyVar.refresh() in parallel: function (event) { var self$ = this.a$; var uid = this.b$.val(); var tid = this.c$.val(); var jqxhr = $.post('/controller1/index',{'uid':uid,'tid':tid,'action':true},function(re) { if(re.message != 'success') { MyVar.alert('' + re.error); MyVar.refresh(); } },'json'); MyVar.refresh(); return stopDefault(event); }; **POSSIBLE SOLUTIONS:** Found this: Apparently it doesn't play well with ajax. One solution is to disallow session update if it is an ajax call; only problem is that our site is mostly built with ajax.. Also, just lowered the sess_time_to_update to something very frequent and ajax was doing fine. Also did a browser refresh and it did not timeout. Not sure why if the session ID has already changed upon an ajax call and browser cookies were never updated.
HTTP 408 is a request timeout and is returned when the server stops waiting for expected input from the browser. Without knowing what your ajax calls look like or what your controller is doing with them, your question is impossible to answer.

以上就是Codeigniter session bugging out with ajax calls的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » jQuery 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准