PHP Classes

File: examples/null.php

Recommend this page to a friend!
  Classes of Colin McKinnon   Stackable PHP Session Handler   examples/null.php   Download  
File: examples/null.php
Role: Example script
Content type: text/plain
Description: The null handler (on top of the compatible handler)
Class: Stackable PHP Session Handler
Store session data with multiple session handlers
Author: By
Last change:
Date: 8 years ago
Size: 1,097 bytes
 

Contents

Class file image Download
<?php

require_once('utils.inc.php');
require_once(
'../handlers/sesspp.inc.php');
require_once(
'../handlers/nullsess.inc.php');
require_once(
'../handlers/compat.inc.php');

session_name('SESS_NUL');

logger("started");
$storage=new compatSessionHandler();
$storage->setLogger('logger');
$handler=new nullHandler($storage);
$handler->setLogger('logger');

if (!
$handler->install()) {
    print
"set handler failed<br /><pre>$statuslog</pre>";
    exit;
}
logger("* about to call session_start()");

session_start();
if (!isset(
$_SESSION['c'])) {
       
$_SESSION['c']=0;
}
if (!(
$_SESSION['c'] % 3)) {
   
logger("* about to regenerate");
   
session_regenerate_id();
}
++
$_SESSION['c'];
logger("about to finish");
session_write_close();
?>
<html>
<H1>The null Handler</H1>
<p>
This handler doesn't do anything! Here it's layered on top of the compatHandler to provide storage.
</p><p>
The reason its here is as a template for you to build your own handler.
</p><p>
The logging output of the handler is shown below:<br />
<?php
print "OK:++\$_SESSION['c']=" . $_SESSION['c'] . "<pre>$statuslog</pre>";
exit;