Application hanging on mac

December 17, 2007

The registration page of an application I was working on wasn’t working on mac – after clicking “submit” on the enter-your-details page the browser would just hang. The application has a page-based structure, so the form is submitted to itself and then if it validates the browser is forwarded to the next page using header(“Location: …”). The problem turned out to be two calls to session_start(). I already had an idea it was the session that was causing a problem because after attempting to register all pages on the site were hanging until I restarted the browser, then I found a post by kyzer at 4u dot net on http://www.php.net/session_start saying recursive session use is impossible, and you can’t fetch “another page on the site which uses sessions, as part of a page which itself uses sessions”.

Now, the application wasn’t exactly doing this, as I would have thought that the header() call is equivalent to calling two separate scripts (i.e. page1 gets executed, sends a location header to the browser, then page2 gets executed without knowing anything about page1) … but in the end I solved the problem by calling session_write_close() before header(“Location: … “).

Kinda puzzling. Good that it’s working now though

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: