|
// +-----------------------------------------------------------------------+
//
//ob_start(); //-- For easy debugging --//
require_once 'PEAR.php';
require_once 'HTTP/Session2.php';
ini_set('error_reporting', E_ALL);
ini_set('display_errors', 1);
//PEAR::setErrorHandling(PEAR_ERROR_DIE);
/*
HTTP_Session2::setContainer(
'DB',
array(
'dsn' => 'mysql://root@localhost/database',
'table' => 'sessiondata'
)
);
*/
HTTP_Session2::useCookies(true);
HTTP_Session2::start('SessionID', uniqid('MyID'));
?>
HTTP Session
\n");
} else {
$variable++;
echo("Yes, it was set already
\n");
}
*/
switch (@$_GET['action']) {
case 'setvariable':
HTTP_Session2::set('variable', 'Test string');
//HTTP_Session2::register('variable');
break;
case 'unsetvariable':
HTTP_Session2::set('variable', null);
//HTTP_Session2::unregister('variable');
break;
case 'clearsession':
HTTP_Session2::clear();
break;
case 'destroysession':
HTTP_Session2::destroy();
break;
}
HTTP_Session2::setExpire(60);
HTTP_Session2::setIdle(5);
//echo("session_is_registered('variable'): '" . (session_is_registered('variable') ? "yes" : "no") . "'
\n");
//echo("isset(\$GLOBALS['variable']): '" . (isset($GLOBALS['variable']) ? "yes" : "no") . "'
\n");
echo("------------------------------------------------------------------
\n");
echo("Session name: '" . HTTP_Session2::name() . "'
\n");
echo("Session id: '" . HTTP_Session2::id() . "'
\n");
echo("Is new session: '" . (HTTP_Session2::isNew() ? "yes" : "no") . "'
\n");
echo("Is expired: '" . (HTTP_Session2::isExpired() ? "yes" : "no") . "'
\n");
echo("Is idle: '" . (HTTP_Session2::isIdle() ? "yes" : "no") . "'
\n");
//echo("Variable: '" . HTTP_Session2::get('variable') . "'
\n");
echo("Session valid thru: '" . (HTTP_Session2::sessionValidThru() - time()) . "'
\n");
echo("------------------------------------------------------------------
\n");
if (HTTP_Session2::isNew()) {
//HTTP_Session2::set('var', 'value');
//HTTP_Session2::setLocal('localvar', 'localvalue');
//blah blah blah
}
?>
Set variable
Unset variable
Destroy session
Clear session data
Reload page