Location: PHPKode > scripts > mSess PHP Class > msess-php-class/page1.php
 //Load Custom Session Library
 require ("mSess.inc");
 $GLOBALS['mSess'] = new mSess ("localhost", "username", "password", "database", "sessionVals");
 $GLOBALS['mSess']->open ();

 if (!isset ($GLOBALS['sessionVals']['myvar'])) {
   $GLOBALS['sessionVals']['myvar'] = "Key in a value!";
 if (isset ($_POST['myvar'])) {
   $GLOBALS['sessionVals']['myvar'] = $_POST['myvar'];
<form method="post" action="page1.php?<?php echo ($GLOBALS['mSess']->getSID ()); ?>">
<input name="myvar" value="<?php echo ($GLOBALS['sessionVals']['myvar']); ?>" /><input type="submit" value="Set Value" />
<p><a href="page1.php?<?php echo ($GLOBALS['mSess']->getSID ()); ?>">If you click this link the page will refresh, but your value will stay if you have set the value.</a></p>
<p><a href="page2.php?<?php echo ($GLOBALS['mSess']->getSID ()); ?>">Click here to go to page 2, and see your value retrieved</a></p>
 //Close Custom Session Library
 $GLOBALS['mSess']->close ();
<div style="border: 1px solid #C0C0C0;">
 //Display Errors
 echo (implode ("\n", $GLOBALS['mSess']->getErrs ()));
Return current item: mSess PHP Class