session_name() and IIS 5.1

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pzbrawl
Forum Newbie
Posts: 12
Joined: Sat Jan 13, 2007 6:13 pm

session_name() and IIS 5.1

Post by pzbrawl »

To allow any user multiple isolated simultaneous sessions in a tabbed browser on an intranet, we set up sessions as shown below. It works fine under Apache 2 and IIS 5.0, but fails under IIS 5.1---sessionb.php receives the session name, but no session values set in sessiona.php are visible in sessionb.php. To make session variables visible in sessionb.php, we have to comment out the session_name() call there, thus destroying session isolation. Is this an IIS 5.1 bug, or is there an IIS 5.1 setting that will fix this problem?

// sessiona.php:
$session_name = 'test' . now();
session_name( $session_name );
session_start();
$_SESSION['info1'] = "info1";
$_SESSION['info2'] = "info2";
$_SESSION['info3'] = "info3";
header( "location:sessionb.php?_sess=$session_name" );
function now() {
$t = microtime();
$sp = strpos( $t, " " );
$p = strpos( $t, "." );
$pt = ($p === false ? 0 : $p );
return substr( $t, ++$sp ) . substr( $t, ++$pt, $sp-$pt );
}

// sessionb.php:
session_name( $_GET['_sess']); // WORKS ONLY IF WE COMMENT THIS OUT
session_start();
echo "Session values:<pre>";
print_r( $_SESSION );
echo "</pre>";
Post Reply