Example #1
0
 /**
  * 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');
 }
 /**
  * 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');
 }
Example #3
0
 /**
  * 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;
     }
 }