本文整理汇总了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'));
}
}
}