Hi all,
For the purposes of this example, I am trying to make it so that session data is remembered for 10 seconds between pages. That is, if you click from Page1 to Page2 within 10 seconds, the session data created on Page1 will be available on Page2. However, if you wait more than 10 seconds before clicking from Page1 to Page2, the session data will not be available on Page2.
Here is the code….
session_page1.php
[code]<?
session_set_cookie_params(10);
session_start();
$_SESSION[‘testvar1’] = “apple”;
$_SESSION[‘testvar2’] = “banana”;
$_SESSION[‘testvar3’] = “catfood”;
?>
<html>
<head>
<title>
SESSION TEST – Page 1/2
</title>
</head>
<body>
<a href=”session_page2.php”>Click to go to Page 2 >></a>
</body>
</html>
session_page2.php
[code]<?
session_start();
$testvar1 = $_SESSION[‘testvar1’];
$testvar2 = $_SESSION[‘testvar2’];
$testvar3 = $_SESSION[‘testvar3’];
?>
<html>
<head>
<title>
SESSION TEST – Page 2/2
</title>
</head>
<body>
<?
echo “testvar1 = “.$testvar1.”<br />”;
echo “testvar2 = “.$testvar2.”<br />”;
echo “testvar3 = “.$testvar3.”<br />”;
?>
</body>
</html>
<?
$_SESSION = array();
session_destroy();
?>
Thus far, the data is showing up every time!
This is probably a bit of a noob question, but between these forums and php.net I’ve tried a hell of a lot without any success thus far!
Can someone show me hwo to do this?
Any info is very much appreciated!
Cheers,
Chris