コード例 #1
0
 public function __construct(\Aliegon\Config $config)
 {
     register_shutdown_function("session_write_close");
     $this->memcache = new \Memcache();
     $this->lifeTime = intval(ini_get("session.gc_maxlifetime"));
     $this->initSessionData = null;
     $sessions = $config->get('sessions');
     foreach ($sessions['servers'] as $ip => $port) {
         $this->memcache->addserver($ip, $port);
     }
     return true;
 }
コード例 #2
0
ファイル: Session.php プロジェクト: devalien/aliegon
 /**
  * Loads the selected Session Handler from the config and starts the actual session
  *
  * @param string $name Name of the session
  */
 private function startSession($name)
 {
     if (!isset($_SESSION)) {
         if (headers_sent()) {
             throw new \Exception('headers already sent by');
         }
         if ($this->config->has('sessions')) {
             $session = $this->config->get('session');
             if (array_key_exists('type', $session)) {
                 $sessionClass = 'Aliegon\\Session\\Handler\\' . ucfirst($session['type']) . 'SessionHandler';
                 $sessionHandler = new $sessionClass($this->getConfig());
                 session_set_save_handler(array(&$sessionHandler, "open"), array(&$sessionHandler, "close"), array(&$sessionHandler, "read"), array(&$sessionHandler, "write"), array(&$sessionHandler, "destroy"), array(&$sessionHandler, "gc"));
             }
             if (array_key_exists('lifetime', $session)) {
                 ini_set("session.gc_maxlifetime", $session['maxlifetime']);
             }
         }
         session_name($name);
         session_start();
     }
 }