Location: PHPKode > scripts > Simple Session Solution > session-simple-5-5/session-simple/session-simple_example.php
<?php

/**
 * Simple Session Solution, Usage Example.
 *
 * @package    SimpleSessionSolution
 * @author     Daniel Convissor <hide@address.com>
 * @copyright  The Analysis and Solutions Company, 2003-2006
 * @version    $Name: rel-5-5 $  $Id: session-simple_example.php,v 1.4 2008/03/30 23:49:55 danielc Exp $
 * @link       http://www.analysisandsolutions.com/software/session-simple/session-simple.htm
 */

/**
 * Require the main file.
 */
include './session-simple.inc';
initializeSession();

?>

<html>
<head><title>Simple Session Solution Example</title></head>
<body>
<h1>Simple Session Solution&trade; Example</h1>

<p>Start a new session: <a href="http://<?php
  echo htmlspecialchars($_SERVER['HTTP_HOST'])
    . htmlspecialchars($_SERVER['SCRIPT_NAME']);
  ?>?SessionID=BOGUS">full link, SessionID=BOGUS</a>
</p>

<p>
  Continue using the session: <a href="<?php
  echo htmlspecialchars($_SERVER['SCRIPT_NAME']);
  ?>">relative link</a>
</p>

<p>
  Continue using the session on SSL connection: <a href="https://<?php
  echo htmlspecialchars($_SERVER['HTTP_HOST'])
    . htmlspecialchars($_SERVER['SCRIPT_NAME']);
  ?><?php echo SESSION_URI_QUERY; ?>">full link with SESSION_URI_QUERY</a>
</p>

<p>
  Leave the session, but don't kill it: <a href="http://<?php
  echo htmlspecialchars($_SERVER['HTTP_HOST'])
    . htmlspecialchars($_SERVER['SCRIPT_NAME']);
  ?>">full link</a>
</p>

<p>
  End the session: <a href="<?php
  echo htmlspecialchars($_SERVER['SCRIPT_NAME']);
  ?>?SessionIDEnd=1">relative link, SessionIDEnd=1</a>
</p>

<form method="post" action="<?php echo htmlspecialchars($_SERVER['SCRIPT_NAME']); ?>">
  <?php echo SESSION_FORM_HIDDEN; ?>
  <input type="submit" name="Continue" value="Continue the session" />
  <input type="submit" name="SessionIDEnd" value="End the session" />
</form>

<?php

if (!isset($_SESSION['i'])) {
    $_SESSION['i'] = 0;
    echo '<p>Session based counter is: 0</p>';
} else {
    echo '<p>Session based counter is: ' . ++$_SESSION['i'] . '</p>';
}

print_r($_SESSION);

?>

</body>
</html>
Return current item: Simple Session Solution