/** * startSession * * @param mixed $context SessionContext * @param mixed $useExisting Whether to use existing session. * * @access public * @return void */ public function startSession($context=null, $useExisting=false) { $logger = $GLOBALS['logger']; $app = $GLOBALS['app']; // Strip '.' $appContext = rtrim($app->getConfiguration()->getApplicationContext(), '.'); if (empty($appContext)) { $appContext = "/"; } else { $appContext = "/".$appContext."/"; } if ($useExisting === true) { $sessionCookieName = $app->getConfiguration()->getApplicationContext()."-"."_n5_session"; $sessionCookieName = preg_replace("/\./", "_",$sessionCookieName); session_set_cookie_params(0, $appContext, null, false, true); session_name($sessionCookieName); session_start(); if (!$this->isActiveSession()) { self::resetActiveSession(); } $this->_session = new Session($_SESSION); if ($this->_session->getAttribute('category') !== null) { return; } } if (!isset($_SESSION[self::GLOBAL_PREFIX.'category'])) { // No session exists yet. if ($context === null) { $context = new WebContext($_REQUEST); } session_unset(); session_destroy(); $sessionCookieName = $app->getConfiguration()->getApplicationContext()."-"."_n5_session"; $sessionCookieName = preg_replace("/\./", "_",$sessionCookieName); session_set_cookie_params(0, $appContext, null, false, true); session_name($sessionCookieName); session_start(); session_regenerate_id(); $_SESSION = array(); $app = $GLOBALS['app']; if (!$app->getConfiguration()->isLocal()) { //$handler = new CachedSessionHandler(); //session_set_save_handler( //array($handler, 'open'), //array($handler, 'close'), //array($handler, 'read'), //array($handler, 'write'), //array($handler, 'destroy'), //array($handler, 'gc') //); } $_SESSION[self::GLOBAL_PREFIX.'category'] = $context->get('device'); $_SESSION[self::GLOBAL_PREFIX.'location'] = $context->get('location'); $_SESSION[self::GLOBAL_PREFIX.'last_accessed'] = time(); }//end if $this->_session = new Session($_SESSION); }//end startSession()
/** * startSession * * @param mixed $context SessionContext * @param mixed $useExisting Whether to use existing session. * * @access public * @return void */ public function startSession($context = null, $useExisting = false) { $logger = $GLOBALS['logger']; if ($useExisting === true) { session_name('_n5_session'); session_start(); $this->_session = new Session($_SESSION); if ($this->_session->getAttribute('category') !== null) { return; } } if (!isset($_SESSION[self::GLOBAL_PREFIX . 'category'])) { // No session exists yet. if ($context === null) { $context = new WebContext($_REQUEST); } session_unset(); session_destroy(); session_set_cookie_params(0, '/', '', false, true); session_name('_n5_session'); session_start(); session_regenerate_id(); $_SESSION = array(); $app = $GLOBALS['app']; if (!$app->getConfiguration()->isLocal()) { //$handler = new CachedSessionHandler(); //session_set_save_handler( //array($handler, 'open'), //array($handler, 'close'), //array($handler, 'read'), //array($handler, 'write'), //array($handler, 'destroy'), //array($handler, 'gc') //); } $_SESSION[self::GLOBAL_PREFIX . 'category'] = $context->get('device'); $_SESSION[self::GLOBAL_PREFIX . 'location'] = $context->get('location'); $_SESSION[self::GLOBAL_PREFIX . 'last_accessed'] = time(); } //end if $this->_session = new Session($_SESSION); }