function __construct()
 {
     ini_set("session.save_handler", "user");
     session_module_name("user");
     session_set_save_handler(array(&$this, "open"), array(&$this, "close"), array(&$this, "read"), array(&$this, "write"), array(&$this, "destroy"), array(&$this, "gc"));
     session_start();
 }
Example #2
0
 public static function init()
 {
     $session_conf = Bd_Conf::getAppConf('session');
     $type = strtolower($session_conf['type']);
     $session_name = $session_conf['session_name'];
     $session_lifetime = $session_conf['lifetime'];
     $session_handler = null;
     if ($session_name) {
         session_name($session_name);
     }
     switch ($type) {
         case 'mysql':
             $db_conf_name = $session_conf['db_conf'];
             $db_conf = self::loadConfName($db_conf_name);
             //$db_proxy = Bd_Db_ConnMgr::getConn($db_conf,"session",false,true);
             //$db_proxy = new Navilib_DBFactory($db_conf);
             $db_conf = Bd_Conf::getConf('/db/' . $db_conf);
             //$session_handler = new Session_Mysql($db_proxy,$session_lifetime);
             $session_handler = new Session_Mysql($db_conf, $session_lifetime);
             break;
         default:
             // 默认存在本地文件
             break;
     }
     if ($session_handler) {
         session_module_name('user');
         //session_save_path('/tmp');
         session_set_save_handler(array(&$session_handler, 'open'), array(&$session_handler, 'close'), array(&$session_handler, 'read'), array(&$session_handler, 'write'), array(&$session_handler, 'destroy'), array(&$session_handler, 'gc'));
     }
 }
 /**
  * Set up the session cache, hijacking handlers from ADODB_Session
  * presumably already in place.
  */
 function _init()
 {
     session_module_name('user');
     session_set_save_handler(array($this, 'open'), array($this, 'close'), array($this, 'read'), array($this, 'write'), array($this, 'destroy'), array($this, 'gc'));
     $this->enabled = TikiLib::lib("memcache")->isEnabled();
     $this->lib = TikiLib::lib("memcache");
 }
function RegisterGlobalState()
{
    /* Deal with user specified session handlers */
    if (session_module_name() == "user") {
        $phperrorcsession = gettext("PHP ERROR: A custom (user) PHP session have been detected. However, BASE has not been set to explicitly use this custom handler.  Set <CODE>use_user_session=1</CODE> in <CODE>base_conf.php</CODE>");
        $phperrorcsessioncode = gettext("PHP ERROR: A custom (user) PHP session hander has been configured, but the supplied hander code specified in <CODE>user_session_path</CODE> is invalid.");
        $phperrorcsessionvar = gettext("PHP ERROR: A custom (user) PHP session handler has been configured, but the implementation of this handler has not been specified in BASE.  If a custom session handler is desired, set the <CODE>user_session_path</CODE> variable in <CODE>base_conf.php</CODE>.");
        if ($GLOBALS['use_user_session'] != 1) {
            ErrorMessage($phperrorcsession);
            die;
        } else {
            if ($GLOBALS['user_session_path'] != "") {
                if (is_file($GLOBALS['user_session_path'])) {
                    ErrorMessage(_("Custom User PHP session handlers are deprecated in this version of SIEM Events Console"));
                    die;
                    //include_once ($GLOBALS['user_session_path']);
                    //if ($GLOBALS['user_session_function'] != "") $GLOBALS['user_session_function']();
                } else {
                    ErrorMessage($phperrorcsessioncode);
                    die;
                }
            } else {
                ErrorMessage($phperrorcsessionvar);
                die;
            }
        }
    }
    //session_start();
    //if ($GLOBALS['debug_mode'] > 0) echo '<FONT COLOR="#FF0000">' . gettext("Session Registered") . '</FONT><BR>';
}
Example #5
0
 function CInstaller()
 {
     $sName = 'WM_INSTALLER';
     if (@session_name() !== $sName) {
         if (@session_name()) {
             @session_write_close();
             if (isset($GLOBALS['PROD_NAME']) && false !== strpos($GLOBALS['PROD_NAME'], 'Plesk')) {
                 @session_module_name('files');
             }
         }
         @session_set_cookie_params(0);
         @session_name($sName);
         @session_start();
     }
     $this->_sState = isset($_GET['step']) ? $_GET['step'] : 'index';
     $this->_aTemplateCache = array();
     $this->_aMenu = array('compatibility', 'license', 'license-key', 'db', 'dav', 'admin-panel', 'email-server-test', 'completed');
     if (@file_exists(WM_INSTALLER_PATH . '../libraries/afterlogic/common/lite.php')) {
         // Lite version steps
         unset($this->_aMenu[2]);
         // 'license-key'
         unset($this->_aMenu[4]);
         // 'dav'
         unset($this->_aSteps['license-key']);
         unset($this->_aSteps['dav']);
     }
 }
Example #6
0
 public function __construct($type = 'cache')
 {
     $this->lifeTime = $GLOBALS['_session_lifetime'];
     //不使用 GET/POST 变量方式
     ini_set('session.use_trans_sid', 0);
     // 是否自动启动
     ini_set('session.auto_start', 0);
     //设置垃圾回收最大生存时间
     ini_set('session.gc_maxlifetime', $this->lifeTime);
     //使用 COOKIE 保存 SESSION ID 的方式
     ini_set('session.use_cookies', 1);
     session_set_cookie_params($GLOBALS['_cookie_expire'], $GLOBALS['_cookie_path'], $GLOBALS['_cookie_domain']);
     //将 session.save_handler 设置为 user,而不是默认的 files
     session_module_name('user');
     switch ($type) {
         case 'memcache':
             ini_set('session.save_handler', $type);
             ini_set('session.save_path', $GLOBALS['_session_path']);
             break;
         case 'cache':
             session_set_save_handler(array($this, "cache_open"), array($this, "cache_close"), array($this, "cache_read"), array($this, "cache_write"), array($this, "cache_destroy"), array($this, "cache_gc"));
             break;
             // 默认使用db
         // 默认使用db
         default:
             session_set_save_handler(array($this, "db_open"), array($this, "db_close"), array($this, "db_read"), array($this, "db_write"), array($this, "db_destroy"), array($this, "db_gc"));
             break;
     }
     session_start();
 }
 public function sessionModuleName($module = null)
 {
     if (null === $module) {
         return session_module_name();
     }
     return session_module_name($module);
 }
Example #8
0
 /**
  * Create a new PHPSession object using the provided options (if any)
  *
  * @param   array   $options    An optional array of ini options to set
  *
  * @throws  ConfigurationError
  * @see     http://php.net/manual/en/session.configuration.php
  */
 public function __construct(array $options = null)
 {
     if ($options !== null) {
         $options = array_merge(self::$defaultCookieOptions, $options);
     } else {
         $options = self::$defaultCookieOptions;
     }
     if (array_key_exists('test_session_name', $options)) {
         $this->sessionName = $options['test_session_name'];
         unset($options['test_session_name']);
     }
     foreach ($options as $sessionVar => $value) {
         if (ini_set("session." . $sessionVar, $value) === false) {
             Logger::warning('Could not set php.ini setting %s = %s. This might affect your sessions behaviour.', $sessionVar, $value);
         }
     }
     $sessionSavePath = session_save_path() ?: sys_get_temp_dir();
     if (session_module_name() === 'files' && !is_writable($sessionSavePath)) {
         throw new ConfigurationError("Can't save session, path '{$sessionSavePath}' is not writable.");
     }
     if ($this->exists()) {
         // We do not want to start a new session here if there is not any
         $this->read();
     }
 }
function RegisterGlobalState()
{
    /* Deal with user specified session handlers */
    if (session_module_name() == "user") {
        if ($GLOBALS['use_user_session'] != 1) {
            ErrorMessage("PHP ERROR: A custom (user) PHP session have been detected. However, ACID has not been " . "set to explicitly use this custom handler.  Set <CODE>use_user_session=1</CODE> in " . "<CODE>acid_conf.php</CODE>");
            die;
        } else {
            if ($GLOBALS['user_session_path'] != "") {
                if (is_file($GLOBALS['user_session_path'])) {
                    include_once $GLOBALS['user_session_path'];
                    if ($GLOBALS['user_session_function'] != "") {
                        $GLOBALS['user_session_function']();
                    }
                } else {
                    ErrorMessage("PHP ERROR: A custom (user) PHP session hander has been configured, but the supplied " . "hander code specified in <CODE>user_session_path</CODE> is invalid.");
                    die;
                }
            } else {
                ErrorMessage("PHP ERROR: A custom (user) PHP session handler has been configured, but the implementation " . "of this handler has not been specified in ACID.  If a custom session handler is desired, " . "set the <CODE>user_session_path</CODE> variable in <CODE>acid_conf.php</CODE>.");
                die;
            }
        }
    }
    session_start();
    if ($GLOBALS['debug_mode'] > 0) {
        echo '<FONT COLOR="#FF0000">Session Registered</FONT><BR>';
    }
}
Example #10
0
 /**
  * Set Session Module
  */
 private function _setSessionModule()
 {
     session_module_name('user');
     session_set_save_handler(array($this, 'open'), array($this, 'close'), array($this, 'read'), array($this, 'write'), array($this, 'destroy'), array($this, 'gc'));
     register_shutdown_function('session_write_close');
     session_start();
 }
Example #11
0
 private function __construct($config = array())
 {
     $this->config = array_merge($this->config, $config);
     if ($this->config['cookie_domain'] == null) {
         $this->config['cookie_domain'] = $_SERVER['HTTP_HOST'];
     }
     if ($this->config['cookie_secure'] === null) {
         $this->config['cookie_secure'] = config::$https;
     }
     if ($this->config['memcache']) {
         if (is_array($this->config['memcache']) && !empty($this->config['memcache']['host']) && !empty($this->config['memcache']['port'])) {
             $host = $this->config['memcache']['host'];
             $port = $this->config['memcache']['port'];
         } else {
             $host = 'localhost';
             $port = 11211;
         }
         session_module_name('memcache');
         session_save_path("tcp://{$host}:{$port}?persistent=1&amp;weight=1&amp;timeout=1&amp;retry_interval=15");
     }
     if (isset($_COOKIE[$this->config['cookie_name']]) && preg_match('/^[a-zA-Z0-9]{' . $this->config['cookie_session_id_key_len'] . '}$/', $_COOKIE[$this->config['cookie_name']])) {
         $this->session_id = $_COOKIE[$this->config['cookie_name']];
     } else {
         $this->session_id = utils::get_random_code($this->config['cookie_session_id_key_len']);
         session_id($this->session_id);
     }
     session_name($this->config['cookie_name']);
     session_set_cookie_params(0, $this->config['cookie_path'], $this->config['cookie_domain'], $this->config['cookie_secure'], $this->config['cookie_http_only']);
     session_start();
 }
Example #12
0
 public function start($sessionName = null)
 {
     if (isset($_SESSION)) {
         return $this;
     }
     Varien_Profiler::start(__METHOD__ . '/setOptions');
     if (is_writable(Mage::getBaseDir('session'))) {
         session_save_path(Mage::getBaseDir('session'));
     }
     Varien_Profiler::stop(__METHOD__ . '/setOptions');
     session_module_name('files');
     /*
             $sessionResource = Mage::getResourceSingleton('core/session');
             $sessionResource->setSaveHandler();
     */
     if ($this->getCookieLifetime() !== null) {
         ini_set('session.gc_maxlifetime', $this->getCookieLifetime());
     }
     if ($this->getCookiePath() !== null) {
         ini_set('session.cookie_path', $this->getCookiePath());
     }
     if ($this->getCookieDomain() !== null) {
         ini_set('session.cookie_domain', $this->getCookieDomain());
     }
     if (!empty($sessionName)) {
         session_name($sessionName);
     }
     // potential custom logic for session id (ex. switching between hosts)
     $this->setSessionId();
     Varien_Profiler::start(__METHOD__ . '/start');
     session_start();
     Varien_Profiler::stop(__METHOD__ . '/start');
     return $this;
 }
Example #13
0
 /**
  * Conigure and start session
  *
  * @param string $sessionName
  * @return Mage_Core_Model_Session_Abstract_Varien
  */
 public function start($sessionName = null)
 {
     if (isset($_SESSION)) {
         return $this;
     }
     switch ($this->getSessionSaveMethod()) {
         case 'db':
             ini_set('session.save_handler', 'user');
             $sessionResource = Mage::getResourceSingleton('core/session');
             /* @var $sessionResource Mage_Core_Model_Mysql4_Session */
             $sessionResource->setSaveHandler();
             break;
         case 'memcache':
             ini_set('session.save_handler', 'memcache');
             session_save_path($this->getSessionSavePath());
             break;
         case 'eaccelerator':
             ini_set('session.save_handler', 'eaccelerator');
             break;
         default:
             session_module_name('files');
             if (is_writable(Mage::getBaseDir('session'))) {
                 session_save_path($this->getSessionSavePath());
             }
             break;
     }
     if (Mage::app()->getStore()->isAdmin()) {
         $adminSessionLifetime = (int) Mage::getStoreConfig('admin/security/session_cookie_lifetime');
         if ($adminSessionLifetime > 60) {
             $this->getCookie()->setLifetime($adminSessionLifetime);
         }
     }
     // session cookie params
     $cookieParams = array('lifetime' => $this->getCookie()->getLifetime(), 'path' => $this->getCookie()->getPath(), 'domain' => $this->getCookie()->getConfigDomain(), 'secure' => $this->getCookie()->isSecure(), 'httponly' => $this->getCookie()->getHttponly());
     if (!$cookieParams['httponly']) {
         unset($cookieParams['httponly']);
         if (!$cookieParams['secure']) {
             unset($cookieParams['secure']);
             if (!$cookieParams['domain']) {
                 unset($cookieParams['domain']);
             }
         }
     }
     if (isset($cookieParams['domain'])) {
         $cookieParams['domain'] = $this->getCookie()->getDomain();
     }
     call_user_func_array('session_set_cookie_params', $cookieParams);
     if (!empty($sessionName)) {
         $this->setSessionName($sessionName);
     }
     // potential custom logic for session id (ex. switching between hosts)
     $this->setSessionId();
     Varien_Profiler::start(__METHOD__ . '/start');
     if ($sessionCacheLimiter = Mage::getConfig()->getNode('global/session_cache_limiter')) {
         session_cache_limiter((string) $sessionCacheLimiter);
     }
     session_start();
     Varien_Profiler::stop(__METHOD__ . '/start');
     return $this;
 }
Example #14
0
 /**
  * 开始使用该驱动的session
  */
 public function begin()
 {
     ini_set('session.gc_maxlifetime', $this->_options['LIFETIME']);
     ini_set('session.cookie_domain', $this->_options['DOMAIN']);
     ini_set('session.use_cookies', 1);
     ini_set('session.cookie_path', '/');
     ini_set('session.hash_bits_per_character', 4);
     session_module_name('user');
     //设置session处理函数
     session_set_save_handler(array($this, 'open'), array($this, 'close'), array($this, 'read'), array($this, 'write'), array($this, 'destroy'), array($this, 'gc'));
     /**
      * When using objects as session save handlers, it is important to register the shutdown function with PHP to avoid unexpected
      * side-effects from the way PHP internally destroys objects on shutdown and may prevent the write and close from being called.
      * Typically you should register 'session_write_close' useing the register_shutdown_function() function.
      * As of PHP 5.4.0 you can use session_register_shutdown() or simply use the 'register shutdown' flag when invoking
      * session_set_save_handler() useing the OOP method and passing an instance that implements SessionHandlerInterface.
      *
      * As of PHP 5.0.5 the write and close handlers are called after object destruction and therefore cannot use objects or throw
      * exceptions. Exceptions are not able to be caught since will not be caught nor will any exception trace be displayed and the
      * execution will just cease unexpectedly. The object destructors can however use sessions.
      * It is possible to call session_write_close() from the destructor to solve this chicken and egg problem but the most reliable
      * way is to register the shutdown function as described above.
      */
     register_shutdown_function('session_write_close');
 }
Example #15
0
 public function __construct($isStart = true)
 {
     if ($isStart) {
         session_module_name('user');
         session_set_save_handler(array($this, 'open'), array($this, 'close'), array($this, 'read'), array($this, 'write'), array($this, 'destory'), array($this, 'gc'));
         session_start();
     }
 }
Example #16
0
 function DbSession_dba(&$dbh, $table)
 {
     $this->_dbh = $dbh;
     ini_set('session.save_handler', 'user');
     session_module_name('user');
     // new style
     session_set_save_handler(array(&$this, 'open'), array(&$this, 'close'), array(&$this, 'read'), array(&$this, 'write'), array(&$this, 'destroy'), array(&$this, 'gc'));
     return $this;
 }
Example #17
0
 function __construct()
 {
     session_module_name('files');
     session_save_path(SESSION_SAVE_PATH);
     session_start();
     $this->sessionId = session_id();
     if (isset($_SESSION[$this->sessionId])) {
         $this->loadSessionData();
     }
 }
Example #18
0
 public function __construct($mem)
 {
     self::$mem = $mem;
     self::$maxtime = ini_get('session.gc_maxlifetime');
     session_module_name('user');
     //session文件保存方式,这个是必须的!除非在Php.ini文件中设置了
     session_set_save_handler(array(__CLASS__, 'open'), array(__CLASS__, 'close'), array(__CLASS__, 'read'), array(__CLASS__, 'write'), array(__CLASS__, 'destroy'), array(__CLASS__, 'gc'));
     session_start();
     //这也是必须的,打开session,必须在session_set_save_handler后面执行
 }
Example #19
0
 /**
  * Opens the memcache based session storage handler
  *
  * @access protected
  */
 protected function _open()
 {
     $this->_conn = new Memcache();
     if ($this->_conn->connect('localhost', 11211) !== true) {
         // fallback to the default PHP session storage mechanism
         session_module_name($this->_orig_module_name);
         return $this->start();
     }
     return true;
 }
 /**
  * Starts the session.
  * The method must be called after initialize().
  * This code cannot be run in initialize(), because initialization has to
  * finish completely, for all instances, before a session can be created:
  * A Database Session Storage must initialize the parent, then itself, and
  * may only then call startup() to auto-start the session.
  * Also, the routing must be fully initialized, too.
  *
  * @author     David Zülke <*****@*****.**>
  * @author     Veikko Mäkinen <*****@*****.**>
  * @since      0.11.0
  */
 public function startup()
 {
     if ($this->hasParameter('session_cache_expire')) {
         session_cache_expire($this->getParameter('session_cache_expire'));
     }
     if ($this->hasParameter('session_cache_limiter')) {
         session_cache_limiter($this->getParameter('session_cache_limiter'));
     }
     if ($this->hasParameter('session_module_name')) {
         session_module_name($this->getParameter('session_module_name'));
     }
     if ($this->hasParameter('session_save_path')) {
         session_save_path($this->getParameter('session_save_path'));
     }
     session_name($this->getParameter('session_name', 'Agavi'));
     $sessionId = session_id();
     $staticSessionId = $this->getParameter('session_id');
     if ($sessionId === '' || $staticSessionId && $sessionId !== $staticSessionId) {
         if ($staticSessionId) {
             session_id($staticSessionId);
         }
         $cookieDefaults = session_get_cookie_params();
         $routing = $this->context->getRouting();
         if ($routing instanceof AgaviWebRouting) {
             // set path to true if the default path from php.ini is "/". this will, in startup(), trigger the base href as the path.
             if ($cookieDefaults['path'] == '/') {
                 $cookieDefaults['path'] = true;
             }
         }
         $lifetime = $this->getParameter('session_cookie_lifetime', $cookieDefaults['lifetime']);
         if (is_numeric($lifetime)) {
             $lifetime = (int) $lifetime;
         } else {
             $lifetime = strtotime($lifetime, 0);
         }
         $path = $this->getParameter('session_cookie_path', $cookieDefaults['path']);
         if ($path === true) {
             $path = $this->context->getRouting()->getBasePath();
         }
         $domain = $this->getParameter('session_cookie_domain', $cookieDefaults['domain']);
         $secure = $this->getParameter('session_cookie_secure', $cookieDefaults['secure']);
         $request = $this->context->getRequest();
         if ($secure === null && $request instanceof AgaviWebRequest) {
             $secure = $request->isHttps();
         } else {
             $secure = (bool) $secure;
         }
         $httpOnly = (bool) $this->getParameter('session_cookie_httponly', $cookieDefaults['httponly']);
         session_set_cookie_params($lifetime, $path, $domain, $secure, $httpOnly);
         session_start();
         if ($lifetime !== 0) {
             setcookie(session_name(), session_id(), time() + $lifetime, $path, $domain, $secure, $httpOnly);
         }
     }
 }
Example #21
0
 public function __construct($isStart = true)
 {
     parent::__construct('session', 'game');
     $this->init_sessions();
     $this->set_expire(300);
     if ($isStart) {
         session_module_name('user');
         session_set_save_handler(array($this, 'open'), array($this, 'close'), array($this, 'read'), array($this, 'write'), array($this, 'destory'), array($this, 'gc'));
         session_start();
     }
 }
Example #22
0
 /**
  * 构造函数
  *
  */
 function __construct()
 {
     if ('cli' == php_sapi_name()) {
         $this->_innerController = new KISS_Controller_Cli();
     } else {
         $application = KISS_Framework_Config::getValue('//application');
         session_name(strtoupper(substr(MD5(KISS_Framework_Config::getSystemPath('root')), 0, 8)));
         if (isset($application['session'])) {
             switch ($application['session']) {
                 case 'disable':
                     break;
                 case 'memcache':
                     $memcache = KISS_Framework_Config::getValue('/application/memcache');
                     if (!isset($memcache['host']) || !isset($memcache['port'])) {
                         die('没有配置 memcache 参数!');
                     }
                     session_save_path("tcp://{$memcache['host']}:{$memcache['port']}?persistent=1&weight=1&timeout=1&retry_interval=5");
                     session_module_name('memcache');
                     KISS_Application::sessionStart();
                     break;
                 case 'redis':
                     $server = KISS_Framework_Config::getValue('/application/session_redis');
                     if (!isset($server['host']) || !isset($server['port'])) {
                         die('没有配置 memcache 参数!');
                     }
                     session_save_path("tcp://{$server['host']}:{$server['port']}?persistent=1&weight=1&timeout=1&database={$server['database']}");
                     session_module_name('redis');
                     KISS_Application::sessionStart();
                     break;
                 default:
                     KISS_Application::sessionStart();
                     break;
             }
         } else {
             KISS_Application::sessionStart();
         }
         if (isset($_SERVER['HTTP_KISS_RPC']) && in_array($_SERVER['HTTP_KISS_RPC'], array('JSON')) && class_exists('KISS_Controller_' . $_SERVER['HTTP_KISS_RPC'])) {
             $Controller = 'KISS_Controller_' . $_SERVER['HTTP_KISS_RPC'];
         }
         if (strpos($_SERVER['PHP_SELF'], '/WEB-INF/') !== false) {
             $_SERVER['PHP_SELF'] = $_SERVER['DOCUMENT_URI'];
         }
         preg_match("/^(_([^_]+)_){0,1}([^\\/]*?)(\\.|\$)/i", basename($_SERVER['PHP_SELF']), $matches);
         if (!isset($Controller)) {
             $Controller = "KISS_Controller_{$matches[2]}";
         }
         if ($Controller == 'KISS_Controller_' || !class_exists($Controller)) {
             $Controller = "KISS_Controller_Brower";
         }
         $class_name = implode('_', array_map('ucfirst', explode('_', $matches[3])));
         $this->_innerController = new $Controller($class_name);
     }
     $this->_innerController->run();
 }
function _register_session_db_functions()
{
	session_module_name('user');
	session_set_save_handler(
	    '_session_db_open',
	    '_session_db_close',
	    '_session_db_read',
	    '_session_db_write',
	    '_session_db_destroy',
	    '_session_db_garbage_collector' );
}
Example #24
0
 /**
  * 构造函数
  * @param array $options 行为参数
  */
 public function __construct($options = array())
 {
     self::$mem = \Norma\Service\Cache::factory('memcache');
     //设置前缀
     self::$mem->setCachePrex('session');
     self::$maxtime = ini_get('session.gc_maxlifetime');
     session_module_name('user');
     //session文件保存方式,这个是必须的!除非在Php.ini文件中设置了
     session_set_save_handler(array(__CLASS__, 'open'), array(__CLASS__, 'close'), array(__CLASS__, 'read'), array(__CLASS__, 'write'), array(__CLASS__, 'destroy'), array(__CLASS__, 'gc'));
     //sae-error
     session_start();
 }
 /**
  * Set it self as save handler
  *
  * @return bool
  */
 public function setSaveHandler()
 {
     session_module_name( 'user' );
     session_set_save_handler(
         array( $this, 'open' ),
         array( $this, 'close' ),
         array( $this, 'read' ),
         array( $this, 'write' ),
         array( $this, 'destroy' ),
         array( $this, 'gc' )
         );
     return true;
 }
 /**
  * Conigure and start session
  *
  * @param string $sessionName
  * @return Mage_Core_Model_Session_Abstract_Varien
  */
 public function start($sessionName = null)
 {
     if (isset($_SESSION)) {
         return $this;
     }
     if (VPROF) {
         Varien_Profiler::start(__METHOD__ . '/setOptions');
     }
     if (is_writable(AO::getBaseDir('session'))) {
         session_save_path($this->getSessionSavePath());
     }
     if (VPROF) {
         Varien_Profiler::stop(__METHOD__ . '/setOptions');
     }
     switch ($this->getSessionSaveMethod()) {
         case 'db':
             ini_set('session.save_handler', 'user');
             $sessionResource = AO::getResourceSingleton('core/session');
             /* @var $sessionResource Mage_Core_Model_Mysql4_Session */
             $sessionResource->setSaveHandler();
             break;
         case 'memcache':
             ini_set('session.save_handler', 'memcache');
             session_save_path($this->getSessionSavePath());
             break;
         default:
             session_module_name('files');
             break;
     }
     AO::dispatchEvent('core_session_before_set_cookie_params');
     // set session cookie params
     session_set_cookie_params($this->getCookie()->getLifetime(), $this->getCookie()->getPath(), $this->getCookie()->getDomain(), $this->getCookie()->isSecure(), $this->getCookie()->getHttponly());
     if (!empty($sessionName)) {
         session_name($sessionName);
     }
     // potential custom logic for session id (ex. switching between hosts)
     $this->setSessionId();
     if (VPROF) {
         Varien_Profiler::start(__METHOD__ . '/start');
     }
     if ($sessionCacheLimiter = AO::getConfig()->getNode('global/session_cache_limiter')) {
         session_cache_limiter((string) $sessionCacheLimiter);
     }
     session_start();
     if (VPROF) {
         Varien_Profiler::stop(__METHOD__ . '/start');
     }
     return $this;
 }
Example #27
0
 /**
  * 初始化
  *
  */
 public static function init()
 {
     $AlphaSession = new Session();
     $AlphaSession->lifeTime = ini_get('session.gc_maxlifetime');
     if (Config::get('session_user_LOC') == 'db') {
         $AlphaSession->handler = Model::getInstance()->db();
     } else {
         $AlphaSession->handler = Model::getInstance()->cache();
     }
     ini_set('session.save_handler', 'user');
     session_module_name('user');
     session_set_save_handler(array($AlphaSession, 'open'), array($AlphaSession, 'close'), array($AlphaSession, 'read'), array($AlphaSession, 'write'), array($AlphaSession, 'destroy'), array($AlphaSession, 'gc'));
     ini_get('session.auto_start') || session_start();
     //自动开启session,必须在session_set_save_handler后面执行
 }
Example #28
0
 /**
  * Conigure and start session
  *
  * @param string $sessionName
  * @return Core_Model_Session_Abstract
  */
 public function start($sessionName = null)
 {
     if (isset($_SESSION)) {
         return $this;
     }
     if (is_writable($this->getSessionSavePath())) {
         session_save_path($this->getSessionSavePath());
     }
     switch ($this->getSessionSaveMethod()) {
         case 'db':
             ini_set('session.save_handler', 'user');
             $sessionResource = App_Main::getResourceSingleton('core/session');
             $sessionResource->setSaveHandler();
             break;
         case 'memcache':
             ini_set('session.save_handler', 'memcache');
             session_save_path($this->getSessionSavePath());
             break;
         default:
             session_module_name('files');
             break;
     }
     /*if ($sessionName == 'backend') {
           $adminSessionLifetime = App_Main::SESSION_ADMIN_LIFETIME;
           if ($adminSessionLifetime > 60) {
               App_Main::getSingleton('core/cookie')->setLifetime($adminSessionLifetime);
           }
       }*/
     // set session cookie params
     session_set_cookie_params($this->getCookie()->getLifetime(), $this->getCookie()->getPath(), $this->getCookie()->getDomain(), $this->getCookie()->isSecure(), $this->getCookie()->getHttponly());
     /*tmp vers */
     $a = $this->getCookie()->getLifetime();
     $b = $this->getCookie()->getPath();
     $c = $this->getCookie()->getDomain();
     $d = $this->getCookie()->isSecure();
     $e = $this->getCookie()->getHttponly();
     if (!empty($sessionName)) {
         $this->setSessionName($sessionName);
     }
     // potential custom logic for session id (ex. switching between hosts)
     $this->setSessionId();
     /*if ($sessionCacheLimiter = App_Main::SESSION_CACHE_LIMITER) {
           session_cache_limiter((string)$sessionCacheLimiter);
       }*/
     session_start();
     return $this;
 }
Example #29
0
 protected function init()
 {
     // Set session config
     $this->_interval = Config::get("storage.session.{$this->_sessnode}.interval", 900);
     // default 15 minutes
     $this->_lifetime = Config::get("storage.session.{$this->_sessnode}.lifetime", 1440);
     // default 24 minutes
     $this->_lifetime_cookie = Config::get("storage.cookie.{$this->_sessnode}.lifetime", 2592000);
     // default 30 days
     $this->_sessname = 'PHPSESSID';
     // default session name
     // Set cookie domain, for muti-host sharing sesssion id
     ini_set('session.cookie_domain', Config::get("storage.cookie.{$this->_sessnode}.domain", ''));
     ini_set('session.cookie_path', Config::get("storage.cookie.{$this->_sessnode}.path", '/'));
     // No transmit session id and use cookie
     ini_set('session.use_trans_sid', 0);
     ini_set('session.use_cookies', 1);
     // Set cookie lifetime and gc_maxlifetime
     ini_set('session.cookie_lifetime', $this->_lifetime_cookie);
     ini_set('session.gc_maxlifetime', $this->_lifetime);
     ini_set('session.gc_probability', 1);
     ini_set('session.gc_divisor', 1000);
     //The probability is calculated by using gc_probability/gc_divisor
     // Change session handler
     session_module_name('user');
     session_set_save_handler($this, TRUE);
     // Set appointed session name, must call before session_start()
     $sess_name = Config::get("storage.session.{$this->_sessnode}.sessname");
     if (!empty($sess_name)) {
         $this->_sessname = $sess_name;
         session_name($this->_sessname);
     }
     // Hack swfupload cookie bug, must call before session_start()
     if (isset($_POST[$this->_sessname]) && $_POST[$this->_sessname] != session_id()) {
         session_id($_POST[$this->_sessname]);
     }
     // OK, session start
     $this->_timestamp = time();
     session_start();
 }
Example #30
0
 function debug()
 {
     if (DEBUG > 2) {
         echo "<hr /><hr /> SESSION DEBUG : <br />";
         print_r($_SESSION);
         echo "<br />";
         echo 'session_name() : ' . session_name() . "<br>\n";
         echo 'session_id() : ' . session_id() . "<br>\n";
         echo 'session_cache_expire() : ' . session_cache_expire() . "<br>\n";
         echo 'session_cache_limiter() : ' . session_cache_limiter() . "<br>\n";
         echo 'session_get_cookie_params() : ';
         print_r(array_values(session_get_cookie_params()));
         echo "<br>\n";
         echo 'session_module_name() : ' . session_module_name() . "<br>\n";
         echo 'session_save_path() : ' . session_save_path() . "<br>\n";
         echo "<hr /><hr /> POST DEBUG : <br />";
         print_r($_POST);
         echo "<hr /><hr /> GET DEBUG : <br />";
         print_r($_GET);
         echo "<hr /><hr />";
     }
 }