当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Session::setSaveHandler方法代码示例

本文整理汇总了PHP中Zend_Session::setSaveHandler方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Session::setSaveHandler方法的具体用法?PHP Zend_Session::setSaveHandler怎么用?PHP Zend_Session::setSaveHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Session的用法示例。


在下文中一共展示了Zend_Session::setSaveHandler方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _initSession

 /**
  * @todo expireSessionCookie()
  * @todo rememberMe(xx)
  * @todo forgetMe()
  * @see Zend_Registry::get('session');
  * @return Zend_Session_Namespace
  */
 protected function _initSession()
 {
     $options = $this->getOption('ca_mgr');
     $db = Zend_Db::factory($options['db']['session']['pdo'], $options['db']['session']);
     /**
      * automatically clean up expired session entries from session cache
      * use the modified and lifetime stamps to calculate expire time
      */
     if ($options['db']['session']['autocleanup'] == '1') {
         $stmt = $db->query('delete from front_session where (modified + lifetime * 2) < unix_timestamp()');
         # $stmt->execute();
     }
     //you can either set the Zend_Db_Table default adapter
     //or you can pass the db connection straight to the save handler $config
     // @see lifetimeColumn / lifetime / overrideLifetime, lifetime defaults to php.ini: session.gc_maxlifetime
     Zend_Db_Table_Abstract::setDefaultAdapter($db);
     $config = array('name' => 'front_session', 'primary' => 'id', 'modifiedColumn' => 'modified', 'dataColumn' => 'data', 'lifetimeColumn' => 'lifetime');
     //create your Zend_Session_SaveHandler_DbTable and
     //set the save handler for Zend_Session
     Zend_Session::setSaveHandler(new Zend_Session_SaveHandler_DbTable($config));
     // Zend_Session::rememberMe(7200);
     //start your session!
     Zend_Session::start();
     $session = new Zend_Session_Namespace();
     if (!isset($session->started)) {
         $session->started = time();
     }
     if (!isset($session->authdata)) {
         $session->authdata = array('authed' => false);
     }
     Zend_Registry::set('session', $session);
     return $session;
 }
开发者ID:NEOatNHNG,项目名称:cacert-testmgr,代码行数:40,代码来源:Bootstrap.php

示例2: _setupEnvironment

 protected function _setupEnvironment()
 {
     error_reporting(E_ALL | E_STRICT);
     set_include_path($this->getPath('library') . PATH_SEPARATOR . $this->getPath('models') . PATH_SEPARATOR . $this->getPath('controllers') . PATH_SEPARATOR . get_include_path());
     require_once 'WebVista/Model/ORM.php';
     require_once 'User.php';
     require_once 'Person.php';
     require_once 'Zend/Session.php';
     require_once 'WebVista/Session/SaveHandler.php';
     Zend_Session::setSaveHandler(new WebVista_Session_SaveHandler());
     Zend_Session::start();
     require_once 'Zend/Loader.php';
     Zend_Loader::registerAutoLoad();
     $sessionTimeout = ini_get('session.gc_maxlifetime') - 5 * 60;
     Zend_Registry::set('sessionTimeout', $sessionTimeout);
     $this->_config = new Zend_Config_Ini($this->getPath('application') . "/config/app.ini", APPLICATION_ENVIRONMENT);
     Zend_Registry::set('config', $this->_config);
     Zend_Registry::set('baseUrl', substr($_SERVER['PHP_SELF'], 0, strpos(strtolower($_SERVER['PHP_SELF']), 'index.php')));
     Zend_Registry::set('basePath', $this->getPath('base') . DIRECTORY_SEPARATOR);
     try {
         date_default_timezone_set(Zend_Registry::get('config')->date->timezone);
     } catch (Zend_Exception $e) {
         die($e->getMessage());
     }
     AuditLog::setDbConfig($this->_config->database->toArray());
     // this MUST be required as this is used as DB connection
     // register shutdown function
     register_shutdown_function(array('AuditLog', 'closeConnection'));
     ob_start();
     // this MUST be required after register shutdown
     return $this;
 }
开发者ID:jakedorst,项目名称:ch3-dev-preview,代码行数:32,代码来源:App.php

示例3: init

 public function init()
 {
     $registry = Zend_Registry::getInstance();
     $auth = Zend_Auth::getInstance();
     $config = $registry->get("config");
     $sessionConfig = $config['resources']['session'];
     $cookieLifetime = $sessionConfig['cookie_lifetime'];
     /* @todo fix issue of system with incoherent behavior when the session
        system has a issue, such as when the savehandler doesn't work as
        expected when it's off-line which results in differents
        catched / uncatched exception when the resource (page) loads
        */
     $saveHandler = new Ml_Session_SaveHandler_PlusCache($registry->get("memCache"), $config['session']['prefix'], $config['lastActivity']['prefix']);
     Zend_Session::setSaveHandler($saveHandler);
     Zend_Session::getSaveHandler()->setLifetime($cookieLifetime, true);
     Zend_Session::start();
     $defaultNamespace = new Zend_Session_Namespace();
     if (!isset($defaultNamespace->initialized)) {
         Zend_Session::regenerateId();
         $defaultNamespace->initialized = true;
     }
     if ($auth->hasIdentity()) {
         $people = Ml_Model_People::getInstance();
         $signedUserInfo = $people->getById($auth->getIdentity());
         $registry->set('signedUserInfo', $signedUserInfo);
     }
     $globalHash = Ml_Model_MagicCookies::getInstance()->getLast(true);
     $registry->set("globalHash", $globalHash);
 }
开发者ID:henvic,项目名称:MediaLab,代码行数:29,代码来源:Mysession.php

示例4: setup

 /**
  * Setup db
  *
  */
 public function setup(Zend_Config $config)
 {
     $sessionConfig = $config->get('config');
     $configArray = $sessionConfig->toArray();
     // save_path handler
     $configArray = $this->_prependSavePath($configArray);
     // name handler
     $configArray = $this->_parseName($configArray);
     // Setup config
     Zend_Session::setOptions($configArray);
     // Setup save handling?
     $saveHandlerConfig = $config->get('save_handler');
     if ($className = $saveHandlerConfig->get('class_name')) {
         if ($args = $saveHandlerConfig->get('constructor_args')) {
             if ($args instanceof Zend_Config) {
                 $args = $args->toArray();
             } else {
                 $args = (array) $args;
             }
         } else {
             $args = array();
         }
         require_once 'Zend/Loader.php';
         Zend_Loader::loadClass($className);
         $saveHandler = new ReflectionClass($className);
         $saveHandler = $saveHandler->newInstanceArgs($args);
         Zend_Session::setSaveHandler($saveHandler);
     }
     // Autostart session?
     if ($config->get('auto_start')) {
         // Start session
         Zend_Session::start();
     }
 }
开发者ID:BGCX262,项目名称:zym-svn-to-git,代码行数:38,代码来源:Session.php

示例5: _initSession

 protected function _initSession()
 {
     if ($this->hasPluginResource('session') && !Zend_Session::getSaveHandler()) {
         Zend_Session::setSaveHandler($this->getPluginResource('session')->getSaveHandler());
     }
     Zend_Session::start();
 }
开发者ID:null-1,项目名称:fangtaitong,代码行数:7,代码来源:Bootstrap.svr.php

示例6: _initSession

 protected function _initSession()
 {
     $configSession = new Zend_Config_Ini(APPLICATION_PATH . '/configs/session.ini', APPLICATION_ENV);
     if (!$this->_request->isInstalling()) {
         $config = array('name' => 'session', 'primary' => 'session_id', 'modifiedColumn' => 'modified', 'dataColumn' => 'data', 'lifetimeColumn' => 'lifetime', 'lifetime' => $configSession->gc_maxlifetime);
         Zend_Session::setSaveHandler(new Zend_Session_SaveHandler_DbTable($config));
     }
     if (!$this->_request->isInstalling() or is_writable(Core_Model_Directory::getSessionDirectory(true))) {
         $types = array();
         $options = $configSession->toArray();
         if (isset($options['types'])) {
             $types = $options['types'];
             unset($options['types']);
         }
         Zend_Session::start($options);
         $session_type = $this->_request->isApplication() ? 'mobile' : 'front';
         $session = new Core_Model_Session($session_type);
         foreach ($types as $type => $class) {
             $session->addType($type, $class);
         }
         $language_session = new Core_Model_Session('language');
         if (!$language_session->current_language) {
             $language_session->current_language = null;
         }
         Core_Model_Language::setSession($language_session);
         Core_View_Default::setSession($session);
         Core_Controller_Default::setSession($session);
     }
 }
开发者ID:BeamlabsTigre,项目名称:Webapp,代码行数:29,代码来源:Bootstrap.php

示例7: init

 /**
  * 系统初始化
  */
 private static function init()
 {
     set_exception_handler(array('AWS_APP', 'exception_handle'));
     self::$config = load_class('core_config');
     self::$db = load_class('core_db');
     self::$plugins = load_class('core_plugins');
     self::$settings = self::model('setting')->get_settings();
     if ((!defined('G_SESSION_SAVE') or G_SESSION_SAVE == 'db') and get_setting('db_version') > 20121123) {
         Zend_Session::setSaveHandler(new Zend_Session_SaveHandler_DbTable(array('name' => get_table('sessions'), 'primary' => 'id', 'modifiedColumn' => 'modified', 'dataColumn' => 'data', 'lifetimeColumn' => 'lifetime')));
         self::$session_type = 'db';
     }
     Zend_Session::setOptions(array('name' => G_COOKIE_PREFIX . '_Session', 'cookie_domain' => G_COOKIE_DOMAIN));
     if (G_SESSION_SAVE == 'file' and G_SESSION_SAVE_PATH) {
         Zend_Session::setOptions(array('save_path' => G_SESSION_SAVE_PATH));
     }
     Zend_Session::start();
     self::$session = new Zend_Session_Namespace(G_COOKIE_PREFIX . '_Anwsion');
     if ($default_timezone = get_setting('default_timezone')) {
         date_default_timezone_set($default_timezone);
     }
     if ($img_url = get_setting('img_url')) {
         define('G_STATIC_URL', $img_url);
     } else {
         define('G_STATIC_URL', base_url() . '/static');
     }
     if (self::config()->get('system')->debug) {
         if ($cornd_timer = self::cache()->getGroup('crond')) {
             foreach ($cornd_timer as $cornd_tag) {
                 if ($cornd_runtime = self::cache()->get($cornd_tag)) {
                     AWS_APP::debug_log('crond', 0, 'Tag: ' . str_replace('crond_timer_', '', $cornd_tag) . ', Last run time: ' . date('Y-m-d H:i:s', $cornd_runtime));
                 }
             }
         }
     }
 }
开发者ID:egogg,项目名称:wecenter-dev,代码行数:38,代码来源:aws_app.inc.php

示例8: init

 public function init()
 {
     $cookie_timeout = 60 * 60 * 24;
     $garbage_timeout = $cookie_timeout + 600;
     $aServerName = explode('.', $_SERVER['SERVER_NAME']);
     $count = count($aServerName);
     $domainName = '.' . $aServerName[$count - 2] . '.' . $aServerName[$count - 1];
     //session_set_cookie_params($cookie_timeout, '/', $domainName);
     session_set_cookie_params(0, '/', $domainName);
     ini_set('session.gc_maxlifetime', $garbage_timeout);
     ini_set('session.cookie_lifetime', $garbage_timeout);
     //		$session = new Zend_Session_Namespace();
     $options = array_change_key_case($this->getOptions(), CASE_LOWER);
     if (isset($options['adapter'])) {
         $adapter = $options['adapter'];
     }
     switch (strtolower($adapter)) {
         case 'remote':
         case 'proxydb':
             $sessionHandler = new Pandamp_Session_SaveHandler_Remote();
             Zend_Session::setSaveHandler($sessionHandler);
             //$this->_saveHandler = $sessionHandler;
             //return $sessionHandler;
             break;
         default:
         case 'directdb':
             $sessionHandler = new Pandamp_Session_SaveHandler_DirectDb($options['db']['adapter'], $options['db']['params']);
             Zend_Session::setSaveHandler($sessionHandler);
             $this->_saveHandler = $sessionHandler;
             return $sessionHandler;
             break;
     }
 }
开发者ID:hukumonline,项目名称:admin,代码行数:33,代码来源:Session.php

示例9: _initSession

 /**
  * initalize session
  */
 protected function _initSession()
 {
     $resource = $this->getPluginResource('db');
     $db = $resource->getDbAdapter();
     Zend_Db_Table_Abstract::setDefaultAdapter($db);
     $config = array('name' => 'sessions', 'primary' => 'sessionId', 'modifiedColumn' => 'modified', 'dataColumn' => 'data', 'lifetimeColumn' => 'lifetime', 'lifetime' => 60 * 60 * 24 * 14);
     Zend_Session::setSaveHandler(new Zend_Session_SaveHandler_DbTable($config));
 }
开发者ID:AlexanderMazaletskiy,项目名称:gym-Tracker-App,代码行数:11,代码来源:Bootstrap.php

示例10: setSaveHandler

 public function setSaveHandler()
 {
     $registry = Zend_Registry::getInstance();
     $application = $registry->get(Pandamp_Keys::REGISTRY_APP_OBJECT);
     $application->getBootstrap()->bootstrap('session');
     $saveHandler = $application->getBootstrap()->getResource('session');
     Zend_Session::setSaveHandler($saveHandler);
 }
开发者ID:hukumonline,项目名称:quart80,代码行数:8,代码来源:Manager.php

示例11: init

 /**
  * Defined by Zend_Application_Resource_Resource
  *
  * @return void
  */
 public function init()
 {
     $options = array_change_key_case($this->getOptions(), CASE_LOWER);
     if (isset($options['savehandler'])) {
         unset($options['savehandler']);
     }
     if (count($options) > 0) {
         Zend_Session::setOptions($options);
     }
     if ($this->_saveHandler !== null) {
         Zend_Session::setSaveHandler($this->_saveHandler);
     }
 }
开发者ID:bitExpert,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:18,代码来源:Session.php

示例12: start

 function start()
 {
     $registry = Zend_Registry::getInstance();
     $config = $registry->get('config');
     $url = $config->session->config->remote->sessionidgenerator->url;
     require_once 'Zend/Session.php';
     $saveHandler = $config->session->savehandler;
     $flagDoSyncSession = $this->_flagDoSyncSession;
     switch (strtolower($saveHandler)) {
         case 'remote':
             require_once 'Kutu/Session/SaveHandler/Remote.php';
             $sessionHandler = new Kutu_Session_SaveHandler_Remote();
             Zend_Session::setSaveHandler($sessionHandler);
             break;
         default:
             $flagDoSyncSession = false;
             break;
     }
     if ($this->_flagDoSyncSession) {
         $flagSessionIdSent = false;
         if (isset($_POST['PHPSESSID']) && !empty($_POST['PHPSESSID'])) {
             $sessid = $_POST['PHPSESSID'];
             Zend_Session::setId($sessid);
             $flagSessionIdSent = true;
         }
         if (isset($_GET['PHPSESSID']) && !empty($_GET['PHPSESSID'])) {
             $sessid = $_GET['PHPSESSID'];
             Zend_Session::setId($sessid);
             $flagSessionIdSent = true;
         }
         if (isset($_COOKIE['PHPSESSID']) && !empty($_COOKIE['PHPSESSID'])) {
             $flagSessionIdSent = true;
         }
         if (!$flagSessionIdSent) {
             //redirect to session local sync startpoint
             $sReturn = "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
             $sReturn = base64_encode($sReturn);
             $url = $config->session->config->local->sync->url;
             $url = KUTU_ROOT_URL . $url;
             header("location: {$url}?returnTo=" . $sReturn);
             exit;
         } else {
             Zend_Session::start();
         }
     } else {
         Zend_Session::start();
     }
 }
开发者ID:hukumonline,项目名称:idh,代码行数:48,代码来源:Manager.php

示例13: __construct

 private function __construct()
 {
     /* Explicitly start the session */
     $config = array('name' => 'session', 'primary' => 'id', 'modifiedColumn' => 'modified', 'dataColumn' => 'data', 'lifetimeColumn' => 'lifetime', 'db' => Zend_Registry::get("dbAdapter"));
     Zend_Session::setSaveHandler(new Zend_Session_SaveHandler_DbTable($config));
     //start your session
     Zend_Session::start();
     /* Create our Session namespace - using 'Default' namespace */
     $this->namespace = new Zend_Session_Namespace();
     /** Check that our namespace has been initialized - if not, regenerate the session id
      * Makes Session fixation more difficult to achieve
      */
     if (!isset($this->namespace->initialized)) {
         Zend_Session::regenerateId();
         $this->namespace->initialized = true;
     }
 }
开发者ID:7thZoneTechnology,项目名称:hrms-1,代码行数:17,代码来源:SessionWrapper.php

示例14: init

 public function init()
 {
     // timeout value for the cookie
     $cookie_timeout = 60 * 60 * 24;
     // in seconds
     //$cookie_timeout = 1440;
     // timeout value for the garbage collector
     // we add 300 seconds, just in case the user's computer clock
     // was synchronized meanwhile; 600 secs (10 minutes) should be
     // enough - just to ensure there is session data until the
     // cookie expires
     $garbage_timeout = $cookie_timeout + 600;
     // in seconds
     // set the PHP session id (PHPSESSID) cookie to a custom value
     session_set_cookie_params($cookie_timeout);
     // set the garbage collector - who will clean the session files -
     // to our custom timeout
     ini_set('session.gc_maxlifetime', $garbage_timeout);
     // ini_set('session.gc_probability', '1');
     // ini_set('session.gc_divisor', '1');
     //die('identity:'.ini_get('session.gc_maxlifetime'));
     $options = array_change_key_case($this->getOptions(), CASE_LOWER);
     if (isset($options['adapter'])) {
         $adapter = $options['adapter'];
         //unset($options['savehandler']);
     }
     switch (strtolower($adapter)) {
         case 'remote':
         case 'proxydb':
             $sessionHandler = new Kutu_Session_SaveHandler_Remote();
             Zend_Session::setSaveHandler($sessionHandler);
             $this->_saveHandler = $sessionHandler;
             return $sessionHandler;
             break;
         default:
         case 'directdb':
             require_once 'Kutu/Session/SaveHandler/DirectDb.php';
             $sessionHandler = new Kutu_Session_SaveHandler_DirectDb($options['db']['adapter'], $options['db']['params']);
             Zend_Session::setSaveHandler($sessionHandler);
             $this->_saveHandler = $sessionHandler;
             return $sessionHandler;
             break;
     }
 }
开发者ID:psykomo,项目名称:kutump,代码行数:44,代码来源:Session.php

示例15: setSaveHandler

 public function setSaveHandler()
 {
     $registry = Zend_Registry::getInstance();
     $config = $registry->get('config');
     $saveHandler = $config->session->savehandler;
     switch (strtolower($saveHandler)) {
         case 'remote':
         case 'proxydb':
             $sessionHandler = new Kutu_Session_SaveHandler_Remote();
             Zend_Session::setSaveHandler($sessionHandler);
             break;
         default:
         case 'directdb':
             require_once 'Kutu/Session/SaveHandler/DirectDb.php';
             $sessionHandler = new Kutu_Session_SaveHandler_DirectDb();
             Zend_Session::setSaveHandler($sessionHandler);
             break;
     }
 }
开发者ID:psykomo,项目名称:kutump-enhanced,代码行数:19,代码来源:Manager.php


注:本文中的Zend_Session::setSaveHandler方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。