本文整理汇总了PHP中Zend_Session::setOptions方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Session::setOptions方法的具体用法?PHP Zend_Session::setOptions怎么用?PHP Zend_Session::setOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Session
的用法示例。
在下文中一共展示了Zend_Session::setOptions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}
}
示例2: authenticate
public function authenticate()
{
// clear any lingering session identities
Zend_Auth::getInstance()->clearIdentity();
$session = $this->initBootstrap()->getApplication()->getOption('session');
$userModel = $this->_adapter->getUser();
if (null === $userModel->user_email || null === $userModel->user_password) {
throw new Zend_Auth_Adapter_Exception('must provide email and password');
}
if ($useremail = $userModel->authenticate($userModel->user_email, $userModel->user_password)) {
$user = new stdClass();
$user->useremail_email = $useremail->getUseremailEmail();
$user->user_id = $useremail->getUser()->getUserId();
$user->user_firstname = $useremail->getUser()->getUserFirstname();
$user->user_lastname = $useremail->getUser()->getUserLastname();
$user->user_admin = $useremail->getUser()->getUserAdmin();
$user->profile_id = $useremail->getUser()->getProfile()->getProfileId();
Zend_Session::setOptions($session);
$auth = Zend_Auth::getInstance();
$storage = $auth->getStorage();
$storage->write($user);
$user = $auth->getIdentity();
return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $user, array('Authentication successful'));
} else {
throw new Zend_Auth_Adapter_Exception('Authentication failed');
}
}
示例3: initSession
/**
* @static
* @return void
*/
public static function initSession()
{
Zend_Session::setOptions(array("throw_startup_exceptions" => false, "gc_maxlifetime" => 7200, "name" => "pimcore_admin_sid", "strict" => false, "use_only_cookies" => false));
try {
// register session
$front = Zend_Controller_Front::getInstance();
if ($front->getRequest() != null && $front->getRequest()->getParam("pimcore_admin_sid")) {
// hack to get zend_session work with session-id via get (since SwfUpload doesn't support cookies)
$_REQUEST["pimcore_admin_sid"] = $front->getRequest()->getParam("pimcore_admin_sid");
$_COOKIE["pimcore_admin_sid"] = $front->getRequest()->getParam("pimcore_admin_sid");
}
if (!empty($_GET["pimcore_admin_sid"])) {
// hack to get zend_session work with session-id via get (since SwfUpload doesn't support cookies)
$_REQUEST["pimcore_admin_sid"] = $_GET["pimcore_admin_sid"];
$_COOKIE["pimcore_admin_sid"] = $_GET["pimcore_admin_sid"];
}
try {
if (!Zend_Session::isStarted()) {
Zend_Session::start();
}
} catch (Exception $e) {
Logger::error("Problem while starting session");
Logger::error($e);
}
} catch (Exception $e) {
Logger::emergency("there is a problem with admin session");
die;
}
}
示例4: _initSession
protected function _initSession()
{
$config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/sessions.ini', 'development');
Zend_Session::setOptions($config->toArray());
// start session
Zend_Session::start();
}
示例5: start
public function start()
{
Varien_Profiler::start(__METHOD__ . '/setOptions');
$options = array('save_path' => Mage::getBaseDir('session'), 'use_only_cookies' => 'off', 'throw_startup_exceptions' => E_ALL ^ E_NOTICE);
if ($this->getCookieDomain()) {
$options['cookie_domain'] = $this->getCookieDomain();
}
if ($this->getCookiePath()) {
$options['cookie_path'] = $this->getCookiePath();
}
if ($this->getCookieLifetime()) {
$options['cookie_lifetime'] = $this->getCookieLifetime();
}
Zend_Session::setOptions($options);
Varien_Profiler::stop(__METHOD__ . '/setOptions');
/*
Varien_Profiler::start(__METHOD__.'/setHandler');
$sessionResource = Mage::getResourceSingleton('core/session');
if ($sessionResource->hasConnection()) {
Zend_Session::setSaveHandler($sessionResource);
}
Varien_Profiler::stop(__METHOD__.'/setHandler');
*/
Varien_Profiler::start(__METHOD__ . '/start');
Zend_Session::start();
Varien_Profiler::stop(__METHOD__ . '/start');
return $this;
}
示例6: 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));
}
}
}
}
}
示例7: testSetOptions
public function testSetOptions()
{
Zend_Session::setOptions(array('use_only_cookies' => false, 'remember_me_seconds' => 3600));
$this->resource->setOptions(array('use_only_cookies' => true, 'remember_me_seconds' => 7200));
$this->resource->init();
$this->assertEquals(1, Zend_Session::getOptions('use_only_cookies'));
$this->assertEquals(7200, Zend_Session::getOptions('remember_me_seconds'));
}
示例8: __construct
/**
* This allow with a config file, to change the cookie_domain of the session.
* Set "session.domain" directive in application.ini to change this.
*
* @param string $namespace
* @param string $member
*/
public function __construct($namespace = self::NAMESPACE_DEFAULT, $member = self::MEMBER_DEFAULT)
{
$cookieDomain = Centurion_Config_Manager::get('session.domain', $_SERVER['SERVER_NAME']);
if ($cookieDomain !== null) {
Zend_Session::setOptions(array('cookie_domain' => $cookieDomain));
}
parent::__construct($namespace, $member);
}
示例9: _initConfig
protected function _initConfig()
{
$config = new Zend_Config($this->getOptions(), true);
Zend_Registry::set('config', $config);
// TODO faut-il utiliser les sessions ou les registres ?
$configSession = new Zend_Config_Ini(__DIR__ . '/configs/session.ini', APPLICATION_ENV);
Zend_Session::setOptions($configSession->toArray());
return $config;
}
示例10: initSessionConfig
public static function initSessionConfig()
{
if (false == self::$sessionInited) {
$dir = APP_PATH . '/runtime/session';
\Zend_Session::setOptions(array('name' => 'sid', 'use_only_cookies' => true, 'use_cookies' => true, 'cookie_lifetime' => 90 * 86400, 'gc_maxlifetime' => 30 * 86400, 'save_path' => $dir, 'save_handler' => 'files', 'cookie_domain' => Dispatcher::getInstance()->getRequest()->getServer('HTTP_HOST')));
ini_set('session.use_strict_mode', false);
self::$sessionInited = true;
}
}
示例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);
}
}
示例12: getSession
private function getSession()
{
static $session;
if (!isset($session)) {
$dir = APP_PATH . '/runtime/session';
if (!is_dir($dir)) {
mkdir($dir, 0755, true);
}
Zend_Session::setOptions(array('cookie_lifetime' => 90 * 86400, 'gc_maxlifetime' => 30 * 86400, 'save_path' => $dir));
Zend_Session::start();
$session = new Zend_Session_Namespace(__METHOD__, Zend_Session_Namespace::SINGLE_INSTANCE);
}
return $session;
}
示例13: _initSession
protected function _initSession()
{
$options = $this->getOptions();
if (!empty($options['session'])) {
Zend_Session::setOptions($options['session']);
}
Zend_Session::start();
foreach ($_COOKIE as $name => $value) {
// remove unused cookies
if ($name[0] == 'w' && strrpos('_height', $name) !== FALSE) {
setcookie($name, '', time() - 3600);
}
}
}
示例14: 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);
// Autostart session?
if ($config->get('auto_start')) {
// Start session
Zend_Session::start();
}
}
示例15: _initSiteBootstrap
protected function _initSiteBootstrap()
{
$config = $this->getOption('site');
$bootstrapClass = $this->_formatModuleName($config['name']) . '_Bootstrap';
$bootstrapPath = $config['path'] . '/Bootstrap.php';
$siteBootstrap = null;
if (file_exists($bootstrapPath)) {
include_once $bootstrapPath;
if (class_exists($bootstrapClass, false)) {
$siteBootstrap = new $bootstrapClass($this);
$siteBootstrap->bootstrap();
}
}
Zend_Session::setOptions(array('cookie_domain' => '.' . $config['host']));
return $siteBootstrap;
}