PHP Classes

File: examples/builtin.php

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


Class file image Download

logger("* about to call session_start()");


if (!isset(
$_SESSION['c'])) $_SESSION['c']=0;

if ((integer)
$_SESSION['c'] && !($_SESSION['c'] % 3)) {
logger("* about to regenerate");
logger("about to finish");
<H1>The Built In Handler</H1>
This script is here to give you an idea of how the performance
of the custom handlers compares with the buit in handler.
Running this on a test machine, not doing much else, and you'll probably be disappointed, though not very surprised
to find that the builtin handler is a lot faster (around 6 times faster on the machine I'm typing this on) than
the custom handlers. But when the traffic volumes ramp up and compete with more meaningful transactions, you'll
see a performance advantage using the nonblocking and/or writeSometimes handlers (remember, you can use both!).
<br />
We can't inject a debug logger into the script so the details below only show what is happening outside the handler:<br />
print "OK:++\$_SESSION['c']=" . $_SESSION['c'] . "<pre>$statuslog</pre>";