Example #1
0
 /**
  * Conigure and start session
  *
  * @param string $sessionName optional session name
  * @return e_session
  */
 public function start($sessionName = null)
 {
     if (isset($_SESSION) && $this->_sessionStarted == true) {
         return $this;
     }
     if (false !== $this->_sessionSavePath && is_writable($this->_sessionSavePath)) {
         session_save_path($this->_sessionSavePath);
     }
     switch ($this->_sessionSaveMethod) {
         case 'db':
             // TODO session db handling, more methods (e.g. memcache)
             ini_set('session.save_handler', 'user');
             $session = new e_db_session();
             $session->setSaveHandler();
             break;
         default:
             session_module_name('files');
             break;
     }
     if (empty($this->_options['domain'])) {
         // MULTILANG_SUBDOMAIN set during initial language detection in language handler
         $doma = (!e_SUBDOMAIN || deftrue('MULTILANG_SUBDOMAIN')) && e_DOMAIN != FALSE ? "." . e_DOMAIN : FALSE;
         // from v1.x
         $this->_options['domain'] = $doma;
     }
     if (empty($this->_options['path'])) {
         $this->_options['path'] = defined('e_HTTP') ? e_HTTP : '/';
     }
     // session name before options - problems reported on php.net
     if (!empty($sessionName)) {
         $this->setSessionName($sessionName);
     }
     // set session cookie params
     session_set_cookie_params($this->_options['lifetime'], $this->_options['path'], $this->_options['domain'], $this->_options['secure'], $this->_options['httponly']);
     if ($this->_sessionCacheLimiter) {
         session_cache_limiter((string) $this->_sessionCacheLimiter);
         //XXX Remove and have e_headers class handle it?
     }
     session_start();
     $this->_sessionStarted = true;
     return $this;
 }
Example #2
0
 /**
  * Conigure and start session
  *
  * @param string $sessionName optional session name
  * @return e_session
  */
 public function start($sessionName = null)
 {
     if (isset($_SESSION)) {
         return $this;
     }
     if (false !== $this->_sessionSavePath && is_writable($this->_sessionSavePath)) {
         session_save_path($this->_sessionSavePath);
     }
     switch ($this->_sessionSaveMethod) {
         case 'db':
             // TODO session db handling, more methods (e.g. memcache)
             ini_set('session.save_handler', 'user');
             $session = new e_db_session();
             $session->setSaveHandler();
             break;
         default:
             session_module_name('files');
             break;
     }
     if (empty($this->_options['domain'])) {
         // MULTILANG_SUBDOMAIN set during initial language detection in language handler
         $this->_options['domain'] = deftrue('MULTILANG_SUBDOMAIN') ? '.' . e_DOMAIN : '';
     }
     if (empty($this->_options['path'])) {
         $this->_options['path'] = defined('e_HTTP') ? e_HTTP : '/';
     }
     // session name before options - problems reported on php.net
     if (!empty($sessionName)) {
         $this->setSessionName($sessionName);
     }
     // set session cookie params
     session_set_cookie_params($this->_options['lifetime'], $this->_options['path'], $this->_options['domain'], $this->_options['secure'], $this->_options['httponly']);
     if ($this->_sessionCacheLimiter) {
         session_cache_limiter((string) $this->_sessionCacheLimiter);
     } elseif (!defined('e_NOCACHE') || !e_NOCACHE) {
         session_cache_limiter('private');
     }
     session_start();
     return $this;
 }