Ejemplo n.º 1
0
 /**
  * Create a new session and copy variables from the old one
  *
  * @return  boolean $result true on success
  *
  * @since   11.1
  */
 public function fork()
 {
     if ($this->_state !== 'active') {
         return false;
     }
     // Keep the old values
     $values = $_SESSION;
     $trans = ini_get('session.use_trans_sid');
     if ($trans) {
         ini_set('session.use_trans_sid', 0);
     }
     $cookie = session_get_cookie_params();
     // Generate a new ID
     session_regenerate_id(true);
     $id = session_id();
     $data = $this->_store->read($this->getId());
     // Kill the session
     session_destroy();
     // Re-register the session store after a session has been destroyed, to avoid PHP bug
     $this->_store->register();
     // Restore config
     ini_set('session.use_trans_sid', $trans);
     session_set_cookie_params($cookie['lifetime'], $cookie['path'], $cookie['domain'], $cookie['secure']);
     // Restart session with new id
     session_id($id);
     session_start();
     $_SESSION = $values;
     // Now put the session data back
     $this->_store->write($id, $data);
 }