PHP Classes

File: examples/compatible.php

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

Contents

Class file image Download
<?php
require_once('utils.inc.php');
require_once(
'../handlers/stackSess.inc.php');
require_once(
'../handlers/compat.inc.php');

session_name('SESS_CP');

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

if (!
$handler->install()) {
    print
"set handler failed";
    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 Compatability Handler</H1>
<p>
This handler is intended to replicate the functionality of the builtin session handler - i.e.
it is a storage handler, using files (and optionally a hierarchy of directories).
</p><p>
As with the standard handler, files are locked between session_start() and session_write_close()
to prevent overlapping read/write cycles. Session data is available after session expiry if
the file has not been removed by garbage collection.
</p><p>
This handler is intended to be used in conjunction with other, more useful handlers - on its
own it provides only the same facilities the builtin handler but at a greater performance/scalability cost.
</p><p>
The logging output of the handler is shown below:<br />
<?php
print "OK:++\$_SESSION['c']=" . $_SESSION['c'] . "<pre>$statuslog</pre>";
exit;