[thelist] PHP, IIS and session_start()

Jeffrey Barke jeffrey.barke at themechanism.com
Sun Sep 7 15:29:42 CDT 2008

On 30 August 2008, I wrote:

> I'm having a problem with sessions in PHP 5.2.4 and IIS . While I've
> tried Googling the answer, I haven't come up with much that seems to
> help.
> Sometimes, and most often after using header('Location: http://someurl.com/')
> , the script times out on session_start().

After switching to custom session handling and storing the sessions in  
a database, I no longer had this problem, but occasionally the session  
data would not be available after the redirect. This meant that people  
were not able to log in--they were just continually redirected back to  
the login page.

However, I found the solution to this new (but related) problem at <http://bugs.php.net/bug.php?id=14636 

Normally, after determining that a user had provided the correct  
credentials, I would write some session variables and then redirect,  
like this:

$_SESSION['var'] = 'val';
header('Location: http://someurl.com/admin/');

With PHP 5.2.4 running under IIS 5 on Windows 2000, I found the  
following to work:

$_SESSION['var'] = 'val';
echo 'a';
header('Location: http://someurl.com/admin/');

Hope this saves someone else some time in the future,
Jeffrey Barke

More information about the thelist mailing list