PHP Classes

File: next.php

Recommend this page to a friend!
  Classes of Justin Koivisto   phpMysqlSessions   next.php   Download  
File: next.php
Role: Example script
Content type: text/plain
Description: Second of 3 test pages
Class: phpMysqlSessions
Author: By
Last change:
Date: 22 years ago
Size: 2,175 bytes


Class file image Download
// 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.)

// Start session or get previous data

// 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.

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

<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>
$var2="If you really want to";
$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.

// Don't forget to save the session data now that it has been modified!
The values have now been modified.<br>
<a href="third.php">Next</a>