1 - When handling yourself the update with SQL queries, test the impact of
INSERT *** ON DUPLICATE KEY UPDATE ***
cf
http://dev.mysql.com/doc/refman/5.0/fr/insert.html2 - Since you are handling in parallel $_SESSION and sql copies of session data, you might consider storing the sql id into the $_SESSION data
When are you doing the first write/ insert?
In some cases $_SESSION is updated only after the page is left...
3 - It seems you are really playing in a dangerous area where precise timing is not really guaranteed and where you should therefore expect lots of troubles.
I would try to reconsider and update session data only on some significant events, so that any cached SQL query has had some time to execute. Your system would then be more robust, and the load on the server would also drop significantly.
Or have some $_SESSION holding the timestamp of the last update and updating only after 2 seconds
Sure, not very Ajax-like but hey, this depends on your SQL server and the stress you put on it. Microseconds or even milli- or centi-seconds updates are fine for Ajax, but not for SQL server