PHP Classes

File: handlers/nullsess.inc.php

Recommend this page to a friend!
  Packages of Colin McKinnon   Stackable PHP Session Handler   handlers/nullsess.inc.php   Download  
File: handlers/nullsess.inc.php
Role: Class source
Content type: text/plain
Description: A null handler - use as a template
Class: Stackable PHP Session Handler
Store session data with multiple session handlers
Author: By
Last change:
Date: 11 years ago
Size: 2,007 bytes
 

 

Contents

Class file image Download
<?php
/**
 * A minimal sessions++ stack component 
 * Does nothing except calling the next in the chain
 */
class nullHandler extends stackSess {
    function __construct($shNext=false) 
    {
        if (false!==$shNext) {
            $this->addNext($shNext);
        }
    }

    function close ()
    {
        if ($this->shStackNext) {
            return $this->shStackNext->close();
        } else {
            return false;
        }
    }
    function destroy($session_id)
     {
        if ($this->shStackNext) {
            return $this->shStackNext->destroy($session_id);
        } else {
            return false;
        }
    }
    function gc($maxlifetime)
    {
        if ($this->shStackNext) {
            return $this->shStackNext->gc($maxlifetime);
        } else {
            return false;
        }
    }
    function open($save_path, $name)
    {
        if ($this->shStackNext) {
                        return $this->shStackNext->open($save_path, $name);
        } else {
            trigger_error("Null session handler has no storage capability");
            return false;
        }
    }
    function read($session_id)
    {
        if ($this->shStackNext) {
            return $this->shStackNext->read($session_id);
        } else {
            return $session_str;
        }
    }
    function write($session_id, $session_data)
    {
        if ($this->shStackNext) {
                        return $this->shStackNext->write($session_id, $session_data);
                } else {
                        return $session_str;
                }
    }
    function create_sid($newlyCreatedSid=false)
    {
        if (is_callable(array($this->shStackNext,'create_sid'))) {
            // we always send down the stack
            $newlyCreatedSid=$this->shStackNext->create_sid($newlyCreatedSid);
        }
        return $newlyCreatedSid;
    }
    function lastAccessed($lastAccess=false)
        {
                if (is_callable(array($this->shStackNext,'lastAccessed'))) {
                        $lastAccess=$this->shStackNext->lastAccessed($lastAccess);
                }
                if (!$lastAccess || $lastAccess>$this->lastAccess) {
            if ($this->lastAccess) {
                            return $this->lastAccess;
            }
                }
                return $lastAccess;
        }
}