I'm trying to implement session on my site for the first time.
For security reasons I have register_globals turned OFF.
What happens is that the session variable don't seem to survive from one page to another. The value of the session variable resets.
For simplicity I have reduced the code but it still won't work - running on WinNT + PHP 4.2.3.
Page 1
******
<?
// Start session before all other headers!
session_start();
// displaying if it's set and it's value, before setting, shows 0 and 0
printf("isset: %d value: %d<BR>", isset($HTTP_SESSION_VARS['userid']), $HTTP_SESSION_VARS['userid'] );
// setting it
$HTTP_SESSION_VARS['userid'] = 2;
// displaying again - shows 1 and 2
printf("isset: %d value: %d<BR>", isset($HTTP_SESSION_VARS['userid']), $HTTP_SESSION_VARS['userid'] );
?>
<!-- Jumping to page 2 -->
<P><A HREF="sess2.php">Session 2</A>
</HTML>
Page 2
******
// Start session before all other headers!
session_start();
// displaying if it's set and it's value, shows 0 and 0 again...should be 1 and 2
printf("isset: %d value: %d<BR>", isset($HTTP_SESSION_VARS['userid']), $HTTP_SESSION_VARS['userid'] );
// setting it again
$HTTP_SESSION_VARS['userid'] = 3;
// // displaying again - shows 1 and 3, but dies again when I jump back
printf("isset: %d value: %d<BR>", isset($HTTP_SESSION_VARS['userid']), $HTTP_SESSION_VARS['userid'] );
?>
<!-- Jumping back -->
<P><A HREF="sess1.php">Session 1</A>
For security reasons I have register_globals turned OFF.
What happens is that the session variable don't seem to survive from one page to another. The value of the session variable resets.
For simplicity I have reduced the code but it still won't work - running on WinNT + PHP 4.2.3.
Page 1
******
<?
// Start session before all other headers!
session_start();
// displaying if it's set and it's value, before setting, shows 0 and 0
printf("isset: %d value: %d<BR>", isset($HTTP_SESSION_VARS['userid']), $HTTP_SESSION_VARS['userid'] );
// setting it
$HTTP_SESSION_VARS['userid'] = 2;
// displaying again - shows 1 and 2
printf("isset: %d value: %d<BR>", isset($HTTP_SESSION_VARS['userid']), $HTTP_SESSION_VARS['userid'] );
?>
<!-- Jumping to page 2 -->
<P><A HREF="sess2.php">Session 2</A>
</HTML>
Page 2
******
// Start session before all other headers!
session_start();
// displaying if it's set and it's value, shows 0 and 0 again...should be 1 and 2
printf("isset: %d value: %d<BR>", isset($HTTP_SESSION_VARS['userid']), $HTTP_SESSION_VARS['userid'] );
// setting it again
$HTTP_SESSION_VARS['userid'] = 3;
// // displaying again - shows 1 and 3, but dies again when I jump back
printf("isset: %d value: %d<BR>", isset($HTTP_SESSION_VARS['userid']), $HTTP_SESSION_VARS['userid'] );
?>
<!-- Jumping back -->
<P><A HREF="sess1.php">Session 1</A>