Location: PHPKode > scripts > phpMysqlSessions > phpmysqlsessions/next.php
<?
	// Need the class definition
	require "_class.session.php";

	// Instantiate a session
	$my_session=new session_class("znet_shop");

	// Remove old session from db (300 sec.)
	$my_session->RemoveExpired(300);

	// Start session or get previous data
	$my_session->Initiate();

	// All the session data should now be in your variable names
	// $var1, $var2, & $var3 are all assigned now, but we need to
	// get our arrays back.
	$array1=unserialize($arr1);
	$array2=unserialize($arr2);

	// Let's print out these arrays separately to show that it worked.
	for($i=0;$i<5;$i++)
		echo "array1[$i] == ".$array1[$i]."<br>";
	echo "array2[\"first\"] == ".$array2["first"]."<br>";
	echo "array2[\"second\"] == ".$array2["second"]."<br>";
	echo "array2[\"third\"] == ".$array2["third"]."<br>";
	echo "array2[\"fourth\"] == ".$array2["fourth"]."<br>";

	$my_sid=$my_session->GetID();
?>
<html><body>
<h1>Session Test</h1>
The following values were in your session database:<br>
Session: <? echo $my_sid?><br>
<table border=3>
 <tr><td>$var1</td><td><? echo $var1 ?></td></tr>
 <tr><td>$var2</td><td><? echo $var2 ?></td></tr>
 <tr><td>$var3</td><td><? echo $var3 ?></td></tr>
 <tr><td>$arr1</td><td><? echo $arr1 ?></td></tr>
 <tr><td>$arr2</td><td><? echo $arr2 ?></td></tr>
</table>
<br>
<?
	$var1=100520034;
	$var2="If you really want to";
	$var3="nothing.";
	for($i=0;$i<5;$i++)
		$array1[$i] = "These are all the same";
	$array2["first"] = "first one";
	$array2["second"] = "second one";
	$array2["third"] = "third one";
	$array2["fourth"] = "fourth one";

	/*	Every time you want to save your values when using an array, you
		must serialize that array. The reason for this is that the serialized
		array is actually what is being stored, not the one you are changing
		values in. There is probably a better way to do it, but this is what
		I found to be the easiest.
	*/
	$arr1=serialize($array1);
	$arr2=serialize($array2);

	// Don't forget to save the session data now that it has been modified!
	$my_session->Save();
?>
The values have now been modified.<br>
<a href="third.php">Next</a>
</body></html>
Return current item: phpMysqlSessions