Re: Ajax (xmlHttpRequest) and session_start() problem.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Robert Cummings wrote:
On Wed, 2006-05-17 at 10:11, Mathijs wrote:
I Have an very strange problem.

When i execute an very simple Ajax request to an PHP script wich just print one line and i put an sleep(20) infront of it, it works perfectly when i refresh the page.

BUT..
When i put session_start() at the top, i can't refresh the page anymore.
It won't refresh untill the server responed.

When i remove the session_start(), i can refresh anytime i want.

Is this a know problem?
Does someone knows an solution?

PHP sessions use locking to avoid race conditions. So you sleep for 20
seconds keeps the lock for just as long, this has the effect of blocking
all other scripts for the same session. To avoid this, grab the session
data you need, and close the session as fast as possible. Additionally,
it's probably a very bad idea to keep the web server waiting for 20
seconds for no good reason. Why not have your javascript do the waiting?

Cheers,
Rob.

This whas just an test example i talked about.
irl, i have an script that does an search on the server for texts in files.

This search goes through an ajax request.
The page that is requested uses $_SESSION.
Therefore i need session_start().

This search can take a while, and if i want to refresh the page, because i want to have an other search or whatever, i just can't. This because, for some reason, when session_start() gets called, it locks the refreshing capeabileties of the browser.

Also, you say to close the session, mabye a stupid question, but how????

If you need more info, just ask :)..

Thx for the quick reply :).

Kind Regards,

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux