<?php
/**
 * example_basic_counter.php
 * 
 * @version $Id: example_basic_count.php 40 2006-01-18 08:20:02Z gerd $
 * 
 * @package patSession
 * @subpackage Examples
 * 
 * @author gERD Schaufelberger <gerd@php-tools.net>
 * @copyright 2004 http://www.php-tools.net
 * @license LGPL
 **/
    // load error handler
    include_once './_error.php';

    // include factory/loader
	include_once '../patSession.php';
	
	// most easy way to create a session object
	$sess	=&	patSession::singleton( 'ham' );

	if( isset( $_REQUEST['restart'] ) &&  $_REQUEST['restart'] == 'force' )
	{
		$sess->restart();
	}
	
	// see wheter the started session is new
	if( $sess->isNew() )
	{
		echo '<b>Hurray!</b> A new session was born! :-)<br />';
	}
	else
	{
		echo '<b>Continue</b> session...<br />';
	}
	
	// recieve the session counter
	echo 'Session  Counter: <b>' . $sess->getCounter() . '</b><br />';
	
	// get query string
	echo '<br />';
	$queryString	=	$sess->getQueryString();
	echo '- <a href="' . $_SERVER['PHP_SELF'] . '?' . $queryString . '" title="'. $_SERVER['PHP_SELF'] . '?' . $queryString .'">Continue this session</a> <br />';
	echo '- <a href="' . $_SERVER['PHP_SELF'] . '" title="'. $_SERVER['PHP_SELF'] . '">Start over</a> (make sure, that you don\'t send cookies!) <br />';
	echo '- <a href="' . $_SERVER['PHP_SELF'] . '?restart=force" title="'. $_SERVER['PHP_SELF'] . '">Restart with cookies</a> (This will destroy the session as well!)<br />';
?>