JSession/fork
From Joomla! Documentation
< API16:JSession
The "API16" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.
Description[edit]
Create a new session and copy variables from the old one
Syntax[edit]
fork()
Returns[edit]
boolean $result true on success
Defined in[edit]
libraries/joomla/session/session.php
Importing[edit]
jimport( 'joomla.session.session' );
Source Body[edit]
public function fork()
{
if ($this->_state !== 'active') {
// @TODO :: generated error here
return false;
}
// save values
$values = $_SESSION;
// keep session config
$trans = ini_get('session.use_trans_sid');
if ($trans) {
ini_set('session.use_trans_sid', 0);
}
$cookie = session_get_cookie_params();
// create new session id
$id = $this->_createId(strlen($this->getId()));
// kill 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();
return true;
}
Examples[edit]
Code Examples[edit]