Hi, I'm relatively new to php and I need help with sessions.
I set the cookie lifetime to 60 in the php.ini file and wanted to test if the cookie expires correctly.
I have one page which initiates a session.
The next page prints out the SID and changes the bkgd color if in session. I'm just trying to follow the example given at onlamp.com
here
I want to be able NOT to access the second page after 60 seconds. I use explorer 6.02 and it doesn't work. The SID never, never changes. The security level for cookies is set at medium.
If I use Netscape 4.7 it works. The SID changes after one minute and I am forced to go back to the first page.
Can someone help?
Are the $HTTP_SESSION_VARS stored in the cookie or do they just become global variables?
Should the $PHPSESSID be unset automatically once the cookie expires?
The first page has this script:
</head>
<?php
// Create a new session
session_start();
// register a variable using httpsessionvars
$bgcolor ="#8080ff";
$HTTP_SESSION_VARS["bgcolor"]="#8080ff";
?>
<body bgcolor="white">
Welcome to a session-enabled page! The background color on the next page will be set to a stylish blue.<p>
<a href = "session2.php">Go to another session-enabled page</a>.
</body>
The second page is this
<?php
// Resume session
session_start ();
// This is to see if the SID changes after 60 seconds
echo $PHPSESSID;
echo "<BR>";
echo $HTTP_SESSION_VARS["bgcolor"];
if (!isset($PHPSESSID)) {
echo "you are not allowed to be here";
?>
<body bgcolor="white">
<?php
} else {
$bgcolor=$HTTP_SESSION_VARS["bgcolor"];
?>
<body bgcolor="<?php echo $bgcolor; ?>">
<?php
print "The new background color is; $bgcolor.";
}
?>
</body>