コード例 #1
0
ファイル: Session.php プロジェクト: JasonWiki/docs
 /**
  * On first session instance creation, sets up the driver and creates session.
  *
  * @param string Force a specific session_id
  */
 protected function __construct($session_id = NULL)
 {
     $this->input = Input::instance();
     // This part only needs to be run once
     if (Session::$instance === NULL) {
         // Load config
         Session::$config = Kohana::config('session');
         // Makes a mirrored array, eg: foo=foo
         Session::$protect = array_combine(Session::$protect, Session::$protect);
         // Configure garbage collection
         ini_set('session.gc_probability', (int) Session::$config['gc_probability']);
         ini_set('session.gc_divisor', 100);
         ini_set('session.gc_maxlifetime', Session::$config['expiration'] == 0 ? 86400 : Session::$config['expiration']);
         // Create a new session
         $this->create(NULL, $session_id);
         if (Session::$config['regenerate'] > 0 and $_SESSION['total_hits'] % Session::$config['regenerate'] === 0) {
             // Regenerate session id and update session cookie
             $this->regenerate();
         } else {
             // Always update session cookie to keep the session alive
             cookie::set(Session::$config['name'], $_SESSION['session_id'], Session::$config['expiration']);
         }
         // Close the session on system shutdown (run before sending the headers), so that
         // the session cookie(s) can be written.
         Event::add('system.shutdown', array($this, 'write_close'));
         // Singleton instance
         Session::$instance = $this;
     }
     Kohana_Log::add('debug', 'Session Library initialized');
 }
コード例 #2
0
ファイル: Session.php プロジェクト: hsyndgn/titan-mvc
 function __construct()
 {
     // Getting config elements
     require APP_DIR . 'config/config.php';
     self::$config = $config;
     // Initialize Session
     self::init();
 }
コード例 #3
0
ファイル: session.class.php プロジェクト: google2013/myqee-1
 public function __construct($vars = null)
 {
     // This part only needs to be run once
     if (null === Session::$instance) {
         // Load config
         Session::$config = Core::config('session');
         if (!isset(Session::$config['check_string']) || !Session::$config['check_string']) {
             Session::$config['check_string'] = '&$@de23#$%@.d3l-3=!#1';
         }
         if (!isset(Session::$config['name']) || !preg_match('#^(?=.*[a-z])[a-z0-9_]++$#iD', Session::$config['name'])) {
             // Name the session, this will also be the name of the cookie
             Session::$config['name'] = 'PHPSESSINID';
         }
         if (IS_DEBUG) {
             $time = microtime(1);
             $is_debug = (bool) Core::debug()->profiler()->is_open();
             if ($is_debug) {
                 Core::debug()->profiler()->start('Core', 'Session StartTime');
             }
         }
         if (isset(Session::$config['driver']) && class_exists('Session_Driver_' . Session::$config['driver'], true)) {
             $driver_name = 'Session_Driver_' . Session::$config['driver'];
             if (isset(Session::$config['driver_config'])) {
                 Session::$driver = new $driver_name(Session::$config['driver_config']);
             } else {
                 Session::$driver = new $driver_name();
             }
         } else {
             Session::$driver = new Session_Driver_Default();
         }
         if (!isset(Session::$config['type']) || Session::$config['type'] != 'url') {
             Session::$config['type'] = 'cookie';
         }
         if (IS_DEBUG) {
             if ($is_debug) {
                 Core::debug()->profiler()->stop();
             }
             # 输出Session启动使用时间
             Core::debug()->info(microtime(1) - $time, 'Session start use time');
         }
         if ($vars) {
             $this->set($vars);
         }
         if (!isset($_SESSION['_flash_session_'])) {
             $_SESSION['_flash_session_'] = array();
         }
         Session::$flash =& $_SESSION['_flash_session_'];
         # 清理Flash Session
         $this->expire_flash();
         $_SESSION['SID'] = Session::$driver->session_id();
         # 确保关闭前执行保存
         Core::register_shutdown_function(array('Session', 'write_close'));
         Session::$instance = $this;
         # 加载用户数据
         Session::load_member_data();
     }
 }
コード例 #4
0
ファイル: Session.php プロジェクト: rogerluiz/Toolkitty
 /**
  * Construct method
  *
  * <code>
  * //when instantiated the class will recover all session information from the config file and start the session
  * $Tk->Load->lib('Session');
  * </code>
  *
  * @param boolean $regenerate_id
  * @return void
  */
 public function __construct($regenerate_id = true)
 {
     self::$config = Load::factory('Config')->session;
     $this->set_config();
     ini_get('session.cookie_lifetime', 84500);
     session_start();
     if ($regenerate_id == true && function_exists('session_regenerate_id')) {
         session_regenerate_id(true);
     }
 }
コード例 #5
0
 /**
  * On first session instance creation, sets up the driver and creates session.
  *
  * @param string Force a specific session_id
  */
 protected function __construct($group = 'default')
 {
     // This part only needs to be run once
     if (self::$instance[$group] === NULL) {
         // Load config
         self::$config = Ko::config('session.' . $group);
         // Configure garbage collection
         ini_set('session.gc_probability', (int) self::$config['gc_probability']);
         ini_set('session.gc_divisor', 100);
         ini_set('session.gc_maxlifetime', self::$config['lifetime'] == 0 ? 86400 : self::$config['lifetime']);
         // Create a new session
         $this->create();
         // Write the session at shutdown
         register_shutdown_function(array($this, 'write_close'));
         // Singleton instance
         self::$instance[$group] = $this;
     }
 }
コード例 #6
0
ファイル: Session.class.php プロジェクト: google2013/myqeecms
 /**
  * On first session instance creation, sets up the driver and creates session.
  */
 public function __construct($vars = null)
 {
     // This part only needs to be run once
     if (Session::$instance === null) {
         // Load config
         Session::$config = Core::config('session');
         if (!isset(Session::$config['name']) || !preg_match('#^(?=.*[a-z])[a-z0-9_]++$#iD', Session::$config['name'])) {
             // Name the session, this will also be the name of the cookie
             Session::$config['name'] = 'PHPSESSINID';
         }
         if (isset(Session::$config['driver']) && class_exists('Session_Driver_' . Session::$config['driver'], true)) {
             $driver_name = 'Session_Driver_' . Session::$config['driver'];
             if (isset(Session::$config['driver_config'])) {
                 $this->driver = new $driver_name(Session::$config['driver_config']);
             } else {
                 $this->driver = new $driver_name();
             }
         } else {
             $this->driver = new Session_Driver_Default();
         }
         if ($vars) {
             // Set the new data
             $this->set($vars);
         }
         if (!isset($_SESSION['_flash_session_'])) {
             $_SESSION['_flash_session_'] = array();
         }
         Session::$flash =& $_SESSION['_flash_session_'];
         # 清理Flash Session
         $this->expire_flash();
         $_SESSION['SID'] = $this->driver->session_id();
         if (!isset($_SESSION['_last_actived_time_']) || TIME - 600 > $_SESSION['_last_actived_time_']) {
             # 更新最后活动时间 10分钟更新一次
             $_SESSION['_last_actived_time_'] = TIME;
         }
         # 确保关闭前执行保存
         Core::register_shutdown_function(array('Session', 'write_close'));
         Session::$instance = $this;
         if (null === Session::$member && isset($_SESSION['member_id']) && $_SESSION['member_id'] > 0) {
             $orm_member = new ORM_Admin_Member_Finder();
             Session::$member = $orm_member->where('id', $_SESSION['member_id'])->find(null, true)->current();
         }
     }
 }
コード例 #7
0
ファイル: Session.class.php プロジェクト: google2013/myqeecms
 public function __construct($vars = null)
 {
     // This part only needs to be run once
     if (Session::$instance === null) {
         // Load config
         Session::$config = Core::config('session');
         if (!isset(Session::$config['name']) || !preg_match('#^(?=.*[a-z])[a-z0-9_]++$#iD', Session::$config['name'])) {
             // Name the session, this will also be the name of the cookie
             Session::$config['name'] = 'PHPSESSINID';
         }
         if (isset(Session::$config['driver']) && class_exists('Session_Driver_' . Session::$config['driver'], true)) {
             $driver_name = 'Session_Driver_' . Session::$config['driver'];
             if (isset(Session::$config['driver_config'])) {
                 $this->driver = new $driver_name(Session::$config['driver_config']);
             } else {
                 $this->driver = new $driver_name();
             }
         } else {
             $this->driver = new Session_Driver_Default();
         }
         if ($vars) {
             // Set the new data
             $this->set($vars);
         }
         if (!isset($_SESSION['_flash_session_'])) {
             $_SESSION['_flash_session_'] = array();
         }
         Session::$flash =& $_SESSION['_flash_session_'];
         # 清理Flash Session
         $this->expire_flash();
         $_SESSION['SID'] = $this->driver->session_id();
         # 确保关闭前执行保存
         Core::register_shutdown_function(array('Session', 'write_close'));
         Session::$instance = $this;
         if (null === Session::$member && isset($_SESSION['member'])) {
             Session::$member = new Member($_SESSION['member']);
         }
     }
 }
コード例 #8
0
 /**
  * On first session instance creation, sets up the driver and creates session.
  */
 public function __construct()
 {
     $this->input = Input::instance();
     // This part only needs to be run once
     if (Session::$instance === NULL) {
         // Load config
         Session::$config = Kohana::config('session');
         // Makes a mirrored array, eg: foo=foo
         Session::$protect = array_combine(Session::$protect, Session::$protect);
         $session_time = Session::$config['expiration'] == 0 ? 86400 : Session::$config['expiration'];
         // Configure garbage collection
         ini_set('session.gc_probability', (int) Session::$config['gc_probability']);
         ini_set('session.gc_divisor', 100);
         ini_set('session.gc_maxlifetime', $session_time);
         // steamshift change
         // Create a new session
         if (isset($_POST["PHPSESSID"])) {
             $this->create(NULL, $_POST["PHPSESSID"]);
         } else {
             $this->create();
         }
         if (Session::$config['regenerate'] > 0 and $_SESSION['total_hits'] % Session::$config['regenerate'] === 0) {
             // Regenerate session id and update session cookie
             $this->regenerate();
         } else {
             // Always update session cookie to keep the session alive
             cookie::set(Session::$config['name'], $_SESSION['session_id'], Session::$config['expiration']);
         }
         // Close the session just before sending the headers, so that
         // the session cookie(s) can be written.
         Event::add('system.send_headers', array($this, 'write_close'));
         // Make sure that sessions are closed before exiting
         register_shutdown_function(array($this, 'write_close'));
         // Singleton instance
         Session::$instance = $this;
     }
     Kohana::log('debug', 'Session Library initialized');
 }
コード例 #9
0
ファイル: Session.php プロジェクト: BGCX261/zr4u-svn-to-git
 /**
  * On first session instance creation, sets up the driver and creates session.
  */
 public function __construct($_session_id = NULL)
 {
     $this->input = Input::instance();
     // This part only needs to be run once
     if (Session::$instance === NULL) {
         // Load config
         Session::$config = Lemon::config('session');
         // Makes a mirrored array, eg: foo=foo
         Session::$protect = array_combine(Session::$protect, Session::$protect);
         // Configure garbage collection
         ini_set('session.gc_probability', (int) Session::$config['gc_probability']);
         ini_set('session.gc_divisor', 100);
         ini_set('session.gc_maxlifetime', Session::$config['expiration'] == 0 ? 86400 : Session::$config['expiration']);
         // Create a new session
         if ($_session_id !== NULL) {
             $this->create(NULL, $_session_id);
         } else {
             $this->create();
         }
         if (Session::$config['regenerate'] > 0 and $_SESSION['total_hits'] % Session::$config['regenerate'] === 0) {
             //log::write('dbglog','do_regenerate'.Session::$config['regenerate'].PHP_EOL,__FILE__,__LINE__);
             // Regenerate session id and update session cookie
             $this->regenerate();
         } else {
             // Always update session cookie to keep the session alive
             cookie::set(Session::$config['name'], $_SESSION['session_id'], Session::$config['expiration']);
         }
         // Close the session just before sending the headers, so that
         // the session cookie(s) can be written.
         Event::add('system.send_headers', array($this, 'write_close'));
         // Make sure that sessions are closed before exiting
         register_shutdown_function(array($this, 'write_close'));
         // Singleton instance
         Session::$instance = $this;
     }
 }
コード例 #10
0
ファイル: ktai_session.php プロジェクト: h-kanjisan/li3_ktai
<?php

//
$config = Session::config();
switch ($config['default']['adapter']) {
    case 'Memory':
        if (empty($_SESSION)) {
            if (Configure::read('Session.model') === null) {
                trigger_error(__("You must set the all Configure::write('Session.*') in core.php to use database storage"), E_USER_WARNING);
                $this->_stop();
            }
            if ($iniSet) {
                ini_set('session.use_trans_sid', 0);
                ini_set('url_rewriter.tags', '');
                ini_set('session.save_handler', 'user');
                ini_set('session.serialize_handler', 'php');
                ini_set('session.use_cookies', 1);
                ini_set('session.name', Configure::read('Session.cookie'));
                ini_set('session.cookie_lifetime', $this->cookieLifeTime);
                ini_set('session.cookie_path', $this->path);
                ini_set('session.auto_start', 0);
            }
        }
        session_set_save_handler(array('CakeSession', '__open'), array('CakeSession', '__close'), array('CakeSession', '__read'), array('CakeSession', '__write'), array('CakeSession', '__destroy'), array('CakeSession', '__gc'));
        break;
    case 'Php':
        if (empty($_SESSION)) {
            if ($iniSet) {
                ini_set('session.use_trans_sid', 0);
                ini_set('session.name', Configure::read('Session.cookie'));
                ini_set('session.cookie_lifetime', $this->cookieLifeTime);