當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。