Skip to end of metadata
Go to start of metadata

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[

Zend Framework: Zend_Session_SaveHandler_DbTable Component Proposal

Proposed Component Name Zend_Session_SaveHandler_DbTable
Developer Notes http://framework.zend.com/wiki/display/ZFDEV/Zend_Session_SaveHandler_DbTable
Proposers Jordan Raub
Felix Jendrusch
Darby Felton, Zend liaison
Revision
  • 1.0 - 4 March 2007: Added proposal draft
  • 1.1 - 20 July 2007: Removed optional Zend_ACL dependency.
  • 1.2 - 24 July 2007: Removed optional Zend_Auth dependency and clarified Zend_Db_Table to Zend_Session_SaveHandler_DbTable relationships
  • 1.3 - 30 July 2007: Added Save_Path and Session name support (both optional). Unit tests written for virtually all configuration modes
  • 1.4 - 1 Aug 2007: Zend_Session_SaveHandler_Db changed to Zend_Session_SaveHandler_DbTable
(wiki revision: 19)

Table of Contents

1. Overview

Zend_Session_SaveHandler_DbTable is a database independent adapter to save session information in a database

2. References

3. Component Requirements, Constraints, and Acceptance Criteria

  • Zend_Session_SaveHandler_DbTable will save session data in a database independent way

4. Dependencies on Other Framework Components

  • Zend_Db_Table
  • Zend_Session_SaveHandler_Interface

5. Theory of Operation

Since Zend_Session_SaveHandler_Interface extends Zend_Db_Table, all normal table operations are available. Also when instantiating a new Zend_Session_SaveHandler_Interface($config), the $config array is a combined config for Zend_Db_Table and Zend_Session_SaveHandler_Interface. So the 'name' and 'primary' keys in my below use case refer to Zend_Db_Table config keys.

In this table id is the actual session ID given to the user. This session id depends on session.hash_function and session.hash_bits_per_character for length I use sha1 with 5bits/char so 32 chars. The defaults for php are session.hash_function refers to md5 and session.hash_bits_per_character = 4. see http://php.net/session

Session modification time in the implemented tables is currently a Unix Timestamp.

Session data column contains the serialized $_SESSION array, as is in the regular save handler seen in files.

Zend_Session_SaveHandler_DbTable saves all data from a session into a single DB table.

Dump of a basic MySQL tables for use with Zend_Session_SaveHandler_DbTable:

UC-01

CREATE TABLE `Sessions` (
`id` varchar(32) NOT NULL,
`modified` int(11) default NULL,
`lifetime` int(11) default NULL,
`data` text,
PRIMARY KEY (`id`)
) ENGINE=InnoDB

UC-02

CREATE TABLE `Sessions` (
`id` varchar(32) NOT NULL,
`save_path` varchar(32) NOT NULL,
`name` varchar(32) NOT NULL default '',
`modified` int(11) default NULL,
`lifetime` int(11) default NULL,
`data` text,
PRIMARY KEY (`id`,`save_path`,`name`)
) ENGINE=InnoDB;

6. Milestones / Tasks

  • Milestone 1: [DONE] Write Proposal
  • Milestone 2: [DONE] Basic Functionallity working with Unit tests
  • Milestone 3: Working prototype checked into the incubator supporting use case #1 along with Unit tests

7. Class Index

  • Zend_Session_SaveHandler_DbTable
  • Zend_Session_SaveHandler_Exception

8. Use Cases

UC-01

The simplest way to use Zend_Session_SaveHandler_DbTable

Now you can use Zend_Session as normal, also if you have some legacy code you can use $_SESSION as you normally would. Everything will be saved in the DB table.

UC-02

You can also have a column for the session Name and/or session.save_path

UC-03

You can also make sessions persistant

9. Class Skeletons

]]></ac:plain-text-body></ac:macro>

]]></ac:plain-text-body></ac:macro>

Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.