Ejemplo n.º 1
0
 /**
  * Start the session
  */
 public static function startSession()
 {
     require_once 'HTTP/Session2.php';
     $user_id = TIP::getUserId();
     if ($user_id) {
         // For a logged in user, use the special TIP container
         HTTP_Session2::useCookies(false);
         HTTP_Session2::setContainer('TIP');
         HTTP_Session2::start('TIP_Session', $user_id);
     } else {
         // For anonymous users, cookie with an automatic session id is used
         HTTP_Session2::useCookies(true);
         HTTP_Session2::start('TIP_Session');
     }
     HTTP_Session2::setExpire(time() + 3600 * 4);
     if (HTTP_Session2::isExpired()) {
         HTTP_Session2::destroy();
         TIP::notifyInfo('session');
     }
 }
Ejemplo n.º 2
0
 /**
  * セッションアダプターのセット
  *
  * @param array $config
  *
  * @return void
  * @throws BEAR_Session_Exception
  */
 private function _setAdpator(array $config)
 {
     // セッションハンドラ初期化
     switch ($config['adapter']) {
         case self::ADAPTER_MEMCACHE:
             ini_set("session.save_handler", 'memcache');
             ini_set("session.save_path", $config['path']);
             break;
         case self::ADAPTER_DB:
             // DSN を指定します
             $config = array('dsn' => $config['path'], 'table' => 'sessiondata', 'autooptimize' => true);
             HTTP_Session2::setContainer('MDB2', $config);
             break;
         case self::ADAPTER_FILE:
             if (isset($config['path']) && file_exists($config['path'])) {
                 ini_set("session.save_path", $config['path']);
             }
             break;
         case self::ADAPTER_NONE:
             // no cache
             break;
         default:
             // error
             $msg = 'Invalid Session Engine.';
             $info = array('adapter' => $config['adapter']);
             throw $this->_exception($msg, array('info' => $info));
     }
 }
Ejemplo n.º 3
0
 // ************ HANDLERS AND OTHER MODULE LOADERS ****************
 include_once dirname(__FILE__) . "/loader.php";
 include_once dirname(__FILE__) . "/module.php";
 // ****************** INITIALIZE SQL CONNECTION ******************
 define('DB_ENGINE', 'mysqli');
 //----- Create SQL database object
 if (!defined('SKIP_SQL_INIT')) {
     $sql = CreateObject('org.freemedsoftware.core.FreemedDb');
 }
 // ********************** START SESSION **************************
 if (!defined('SESSION_DISABLE') and !defined('SKIP_SQL_INIT')) {
     LoadObjectDependency('net.php.pear.HTTP_Session2');
     HTTP_Session2::useTransSID(false);
     HTTP_Session2::useCookies(true);
     // using an existing MDB2 connection
     HTTP_Session2::setContainer('MDB2', array('dsn' => $GLOBALS['sql']->GetMDB2Object(), 'table' => 'session'));
     HTTP_Session2::start();
     HTTP_Session2::setExpire(time() + 60 * 60);
     // set expire to 60 minutes
     HTTP_Session2::setIdle(time() + 10 * 60);
     // set idle to 10 minutes
     if (HTTP_Session2::isExpired()) {
         syslog(LOG_INFO, "Session expired!!");
         HTTP_Session2::destroy();
     }
     if (HTTP_Session2::isIdle()) {
         syslog(LOG_INFO, "Session became idle");
         HTTP_Session2::destroy();
     }
     HTTP_Session2::updateIdle();
     if (HTTP_Session2::isNew()) {