Forum Moderators: coopster
[2]
$AccessFE= (isset($_SESSION['AccessFE']) or (preg_match('/^AccessFEClient/',$_SERVER['HTTP_USER_AGENT']))) ? true:false;
[/2] I know that the preg_match would be more efficient if using strpos() and I'm going to change the code to do that anyway but still, it's a fairly simple regex and I can't see why this line should stall the page?
It's not happening every time but seems to happen a few requests in a row from the same client and then not again. The Session variables aren't huge (<10 keys) so I don't think it can be the isset.
PHP is 5.2.6 running as an Apache 2.2 module on a Windows 2003 server.
Any tips would be welcome.
Nothing there that should be setting off execution alarms. I don't believe this line is your issue, not at first glance anyway. How about your session? Are you starting your session first? Try commenting out this line and or using an exit [php.net] right before this statement to see if your script still times out.
The timeout is reported at line 286 (which is this one). The previous line is session_start(). Could it be that that is timing out?
I have been unable to reproduce the problem on my staging server, it only happens (and then intermittently) on the production server, so unfortunately commenting out / using exit is not really an option.
Andrew
Could it be that that is timing out?
I believe so. The next line is nothing, should run lightning fast and without issue. However, your server is choking on the session_start for some reason by the looks of it. I would review the logs to see what is going on. You could always set up a test subdomain on your live server too so you can play around in that sandbox without knocking your production domain offline.
The file download script was keeping a lock on the session file for the duration of the download.
I added a call to session_write_close immediately prior to the download in the download script, now it works perfectly.
Thanks for the pointer. Every day's a learning day.
Cheers,
Andrew
if (isset($_SESSION)) {session_write_close(); }
header('Location: http://www.example.com/');
exit;