Forum Moderators: coopster

Message Too Old, No Replies

Simultaneous AJAX calls and Sessions

Simultaneous AJAX calls from the same client being queued

         

trevordixon

5:51 pm on May 13, 2008 (gmt 0)

10+ Year Member



I have a page that makes two GET requests to two different handlers. The second request never completes (or even really starts) until the first is finished (and the first request stays open for a very long time).

A .Net developer was having the same issue until he implemented IReadOnlySessionState instead of IRequiresSessionState. I don't know what that means, but I think my problem is a session problem too, because when I change the first request's handler to not use sessions, AJAX calls made while the first is still open complete fine. But if session_start() is called, subsequent requests can't complete.

So how can I make it so that calls can be made simultaneously and still both use sessions?

trevordixon

7:35 pm on May 13, 2008 (gmt 0)

10+ Year Member



Problem solved, when session_start() was called, the session file was locked up, so other scripts that operated on the session couldn't continue past session_start() until the script was finished.

The key was to call session_write_close() after I was done with the session so that the other script could continue.

eelixduppy

10:34 pm on May 13, 2008 (gmt 0)



Glad you found your solution! Thanks for sharing :)

WesleyC

3:27 pm on May 14, 2008 (gmt 0)

10+ Year Member



One thing I might like to add to this discussion--consider implementing a database session handler. By default, PHP uses a file-based session handler, which can cause errors like this. However, using a database eliminates this problem and can actually improve performance slightly, if a good database structure is used.