<?php
require_once('utils.inc.php');
require_once('../handlers/stackSess.inc.php');
require_once('../handlers/nonBlocking.inc.php');
require_once('../handlers/writeSometimes.inc.php');
session_name('SESS_SN');
logger("started");
$storage=new nonBlockingHandler();
$storage->setLogger('logger');
$handler=new writeSometimes($storage);
$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 ((integer)$_SESSION['c'] && !($_SESSION['c'] % 3)) {
logger("* about to regenerate");
session_regenerate_id();
if (version_compare(PHP_VERSION, '5.5.1') < 0) {
$handler->create_sid('dummy string');
}
}
if ((integer)$_SESSION['c'] && !($_SESSION['c']=10)) {
logger("triggering gc");
$handler->gc(6400);
}
logger("about to finish");
session_write_close();
?>
<html>
<H1>The write Sometimes Handler + non Blocking storage</H1>
<p>
<p>This combination should give good performance characterisitcs - but see the pages
for each seperate handler for thecaveats.<br />
This handler only passes on writes to the lower layer if:
<ul>
<li>The session has changed</li>
<li>The session ID has changed</li>
<li>The session has reached 70% of its TTL</li>
</ul>
</p><p>
While the other demos change the session each time, this only increments
the counter based on a throw of the dice so you see the effect of
omitting the write. That means it has 3 distinct behaviours:
<ul>
<li>no write</li>
<li>write session</li>
<li>write session with new session id</li>
</ul>
</p><p>
The logging output of the handler is shown below:<br />
<?php
print "OK:++\$_SESSION['c']=" . $_SESSION['c'] . "<pre>$statuslog</pre>";
exit;
|