2个同步AJAX上的CodeIgniter $ this-> session-> set_userdata()

I have simulatneous AJAX requests on codeIgniter with all of them session update like so:

function ajax1($value)
{
    $this->session->set_userdata('foo', $value);
}

function ajax2($value)
{
    $this->session->set_userdata('bar', $value);
}

But sometimes because of MySQL concurrency, one variable or the other is not updated, I suppose because one method gets overwrites the new value of the other method with the old value if grabbed from the db.

I cannot update the 2 sessions at the same time as they do completely different things and I don't know which ones will be called, as the page is dynamic and might have one or several of these method calls.

Anybody ran into this in the past and has a way of going around that problem?

I think this problem was fixed in the latest version of codeIgniter, but if you are still using an old one, try to replace system/libraries/Session.php with a new one, or you can just override the Session Library like follow:

application/libraries/MY_Session.php

class MY_Session extends CI_Session
{
    function sess_update()
    {
        if (!$this->CI->input->is_ajax_request())
            return parent::sess_update();
    }

}