Re: Ajax (xmlHttpRequest) and session_start() problem.
| From: | Mathijs | Date: | Wed, 17 May 2006 16:38:04 +0000 |
| Subject: | Re: Ajax (xmlHttpRequest) and session_start() problem. | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-236354@lists.php.net to get a copy of this message | ||
Thank you very much :D.
Ill just create an class which will handle this :).
It works like a charm..
Thx.
Thomas Munz wrote:
session_write_close(); Ex: session_start(); $asdf = $_SESSION; //-- get all datas session_write_close(); //-- close session on Wednesday 17 May 2006 16:36, Mathijs wrote:--- avast! Antivirus: Outbound message clean. Virus Database (VPS): 0620-0, 05/15/2006 Tested on: 5/17/2006 6:38:04 PM avast! - copyright (c) 1988-2006 ALWIL Software. http://www.avast.comRobert Cummings wrote:--- avast! Antivirus: Inbound message clean. Virus Database (VPS): 0620-0, 05/15/2006 Tested on: 5/17/2006 6:37:16 PM avast! - copyright (c) 1988-2006 ALWIL Software. http://www.avast.comOn Wed, 2006-05-17 at 10:11, Mathijs wrote: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,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.