Exemple #1
0
 /**
  * Create a new session.
  *
  * @param   array  variables to set after creation
  * @return  void
  */
 public function create($vars = null)
 {
     $cookieconfig = Core::config('cookie');
     $_SESSION = array();
     $sid = Core::cookie()->get($this->session_name);
     if (!$sid || !$this->_check_session_id($sid)) {
         $sid = md5(TIME . '_^_^_' . rand(1000, 99999999) . '_IP:' . HttpIO::IP);
         # 将session存入cookie
         Core::cookie()->set($this->session_name, $sid, null, $cookieconfig['path'], $cookieconfig['domain'], $cookieconfig['secure'], $cookieconfig['httponly']);
     }
     $this->driver()->session_mode(true);
     $_SESSION = $this->driver()->get($sid);
     $this->driver()->session_mode(false);
     if (!is_array($_SESSION)) {
         $_SESSION = array();
     }
     # 将获取的值序列化MD5值
     Session_Driver_Cache::$OLD_SESSION_MD5 = md5(serialize($_SESSION));
     # 当前session id
     Session_Driver_Cache::$Session_ID = $sid;
 }
Exemple #2
0
 /**
  * Create a new session.
  *
  * @return  void
  */
 public function create()
 {
     $cookie_config = Core::config('cookie');
     $_SESSION = array();
     if (Session::$config['type'] == 'url') {
         $sid = HttpIO::GET($this->session_name);
     } else {
         $sid = HttpIO::COOKIE($this->session_name);
     }
     if (!$sid || !Session::check_session_id($sid)) {
         $sid = Session::create_session_id();
         if (Session::$config['type'] == 'cookie') {
             # 将session存入cookie
             Core::cookie()->set($this->session_name, $sid, null, $cookie_config['path'], $cookie_config['domain'], $cookie_config['secure'], $cookie_config['httponly']);
         }
     }
     # 添加URL处理自动追加SESSION ID参数
     if (Session::$config['type'] == 'url') {
         Core::add_url_args(Session::$config['name'], $sid);
     }
     # 调试模式设置Session模式,避免开启缓存模式时获取不到Session
     if (IS_DEBUG) {
         $this->driver()->session_mode(true);
     }
     $_SESSION = $this->driver()->get($sid);
     if (IS_DEBUG) {
         $this->driver()->session_mode(false);
     }
     if (!is_array($_SESSION)) {
         $_SESSION = array();
     }
     # 将获取的值序列化MD5值
     Session_Driver_Cache::$OLD_SESSION_MD5 = md5(serialize($_SESSION));
     # 当前session id
     Session_Driver_Cache::$Session_ID = $sid;
 }