Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
- $sessionConfig = array(
- 'name' => 'Sessions', //table name as per Zend_Db_Table
- 'primary' => 'id', //the sessionID given by php
- 'modifiedColumn' => 'modified', //time the session should expire
- 'dataColumn' => 'data', //serialized data
- 'lifetimeColumn' => 'lifetime' //end of life for a specific record
- );
- $saveHandler = new Zend_Session_SaveHandler_DbTable($sessionConfig);
- //cookie persist for 30 days
- Zend_Session::rememberMe($seconds = (60 * 60 * 24 * 30));
- //make the session persist for 30 days
- $saveHandler->setLifetime($seconds)
- ->setOverrideLifetime(true);
- //similarly,
- //$saveHandler->setLifetime($seconds, true);
- Zend_Session::setSaveHandler($saveHandler);
- Zend_Session::start();
- resources.db.isDefaultTableAdapter = true
- resources.db.adapter = "pdo_mysql"
- resources.db.params.host = "localhost"
- resources.db.params.dbname = "dbname"
- resources.db.params.username = "username"
- resources.db.params.password = "password"
- protected function _initSession() {
- $resource = $this->getPluginResource('db');
- $dbAdapter = $db = $resource->getDbAdapter();
- Zend_Registry::set("db", $dbAdapter);
- Zend_Db_Table_Abstract::setDefaultAdapter($dbAdapter);
- $config = array(
- 'name' => 'session',
- 'primary' => 'id',
- 'modifiedColumn' => 'modified',
- 'dataColumn' => 'data',
- 'lifetimeColumn' => 'lifetime',
- 'db' => $dbAdapter
- );
- Zend_Session::setSaveHandler(new Zend_Session_SaveHandler_DbTable($config));
- Zend_Session::start();
- }
- DROP TABLE IF EXISTS `session`;
- CREATE TABLE `session` (
- `id` char(32) NOT NULL DEFAULT '',
- `modified` int(11) DEFAULT NULL,
- `lifetime` int(11) DEFAULT NULL,
- `data` text,
- PRIMARY KEY (`id`)
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Add Comment
Please, Sign In to add comment