[ class tree: HTTP_Session2 ] [ index: HTTP_Session2 ] [ all elements ]

Class: HTTP_Session2_Container_MDB2

Source Location: /HTTP_Session2-0.7.3/HTTP/Session2/Container/MDB2.php

Class Overview


Database container for session data



  • Release: @package_version@



Inherited Variables

Inherited Methods

Class: HTTP_Session2_Container

Constrtuctor method
Parse options passed to the container class
Set session save handler
Set some default options
Call session_write_close() in destructor for compatibility with PHP >= 5.0.5

Class Details

[line 54]
Database container for session data

Create the following table to store session data

  1.  CREATE TABLE `sessiondata` (
  2.      `id` CHAR(32NOT NULL,
  3.      `expiry` INT UNSIGNED NOT NULL DEFAULT 0,
  4.      `data` TEXT NOT NULL,
  5.      PRIMARY KEY (`id`)
  6.  );

[ Top ]

Class Variables

$crc =  false

[line 69]

Session data cache id
  • Access: protected

Type:   mixed

[ Top ]

$db =  null

[line 62]

MDB2 connection object
  • Access: protected

Type:   object DB

[ Top ]

Method Detail

__construct (Constructor)   [line 87]

object __construct( array $options)

Constrtuctor method

$options is an array with the options.
The options are:

  • 'dsn' - The DSN string
  • 'table' - Table with session data, default is 'sessiondata'
  • 'autooptimize' - Boolean, 'true' to optimize the table on garbage collection, default is 'false'.

  • Access: public

Overrides HTTP_Session2_Container::__construct() (Constrtuctor method)


array   $options   —  The options

[ Top ]

close   [line 161]

boolean close( )

Free resources
  • Access: public

[ Top ]

connect   [line 100]

boolean connect( mixed $dsn)

Connect to database by using the given DSN string
  • Throws: HTTP_Session2_Exception An exception?!
  • Access: protected


mixed   $dsn   —  DSN string or MDB2 object

[ Top ]

destroy   [line 261]

boolean destroy( string $id)

Destroy session data
  • Throws: HTTP_Session2_Exception An exception containing MDB2 data.
  • Access: public


string   $id   —  The id.

[ Top ]

gc   [line 286]

boolean gc( int $maxlifetime)

Garbage collection

Currently supported are mysql, mysqli and pgsql.

  • Todo: Fix database-specific garbage collection.
  • Throws: HTTP_Session2_Exception An exception that contains MDB2 data.
  • Access: public


int   $maxlifetime   —  The session's maximum lifetime.

[ Top ]

open   [line 151]

boolean open( string $save_path, string $session_name)

Establish connection to a database
  • Access: public
  • Uses: self::connect();
  • Uses: self::$options


string   $save_path   —  The path to save/write sessions.
string   $session_name   —  The session name.

[ Top ]

read   [line 178]

mixed read( string $id)

Read session data
  • Todo: Get rid off sprintf()
  • Throws: HTTP_Session2_Exception An exception!?
  • Access: public


string   $id   —  The Id!

[ Top ]

replicate   [line 319]

boolean replicate( string $target, [string $id = null])

Replicate session data to specified target
  • Throws: HTTP_Session2_Exception To carry any MDB2 related error out.
  • Access: public


string   $target   —  The target (table) to replicate to.
string   $id   —  Id of record to replicate, if not specified current session id will be used

[ Top ]

setDefaults   [line 134]

void setDefaults( )

Set some default options
  • Access: protected

Overrides HTTP_Session2_Container::setDefaults() (Set some default options)
[ Top ]

write   [line 203]

boolean write( string $id, string $data)

Write session data
  • Todo: Remove sprintf(), they are expensive.
  • Access: public


string   $id   —  The id.
string   $data   —  The data.

[ Top ]

Documentation generated on Wed, 09 Dec 2015 22:48:57 +0000 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.