當前位置: 首頁>>代碼示例>>PHP>>正文


PHP SessionHandler::singleton方法代碼示例

本文整理匯總了PHP中SessionHandler::singleton方法的典型用法代碼示例。如果您正苦於以下問題:PHP SessionHandler::singleton方法的具體用法?PHP SessionHandler::singleton怎麽用?PHP SessionHandler::singleton使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在SessionHandler的用法示例。


在下文中一共展示了SessionHandler::singleton方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setupSessionHandler

 /**
  * Sets a custom session handler up, if there is one.
  * If the global variable 'session_cache_limiter' is defined, its value
  * will override the cache limiter setting found in the configuration
  * file.
  */
 function setupSessionHandler()
 {
     global $conf;
     ini_set('url_rewriter.tags', 0);
     if (!empty($conf['session']['use_only_cookies'])) {
         ini_set('session.use_only_cookies', 1);
         if (!empty($conf['cookie']['domain']) && strpos($conf['server']['name'], '.') === false) {
             Horde::fatal('Session cookies will not work without a FQDN and with a non-empty cookie domain. Either use a fully qualified domain name like "http://www.example.com" instead of "http://example" only, or set the cookie domain in the Horde configuration to an empty value, or enable non-cookie (url-based) sessions in the Horde configuration.', __FILE__, __LINE__);
         }
     }
     session_set_cookie_params($conf['session']['timeout'], $conf['cookie']['path'], $conf['cookie']['domain'], $conf['use_ssl'] == 1 ? 1 : 0);
     session_cache_limiter(Util::nonInputVar('session_cache_limiter', $conf['session']['cache_limiter']));
     session_name(urlencode($conf['session']['name']));
     $type = !empty($conf['sessionhandler']['type']) ? $conf['sessionhandler']['type'] : 'none';
     if ($type == 'external') {
         $calls = $conf['sessionhandler']['params'];
         session_set_save_handler($calls['open'], $calls['close'], $calls['read'], $calls['write'], $calls['destroy'], $calls['gc']);
     } elseif ($type != 'none') {
         require_once 'Horde/SessionHandler.php';
         $sh =& SessionHandler::singleton($conf['sessionhandler']['type'], array_merge(Horde::getDriverConfig('sessionhandler', $conf['sessionhandler']['type']), array('memcache' => !empty($conf['sessionhandler']['memcache']))));
         if (is_a($sh, 'PEAR_Error')) {
             Horde::fatal(PEAR::raiseError('Horde is unable to correctly start the custom session handler.'), __FILE__, __LINE__, false);
         } else {
             ini_set('session.save_handler', 'user');
             session_set_save_handler(array(&$sh, 'open'), array(&$sh, 'close'), array(&$sh, 'read'), array(&$sh, 'write'), array(&$sh, 'destroy'), array(&$sh, 'gc'));
         }
     }
 }
開發者ID:justinlyon,項目名稱:scc,代碼行數:34,代碼來源:Horde.php


注:本文中的SessionHandler::singleton方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。