/**
* Returns the object of the active session.
* Tries to find an existing session.
* Otherwise creates a new session.
*
* @return Session $session
*/
public function get()
{
// get session id
$this->sessionID = $this->readSessionID();
$this->session = null;
// get existing session
if (!empty($this->sessionID)) {
$this->session = $this->getExistingSession($this->sessionID);
}
// create new session
if ($this->session == null) {
$this->session = $this->create();
}
self::$activeSession = $this->session;
// call shouldInit event
if (!defined('NO_IMPORTS')) {
EventHandler::fireAction($this, 'shouldInit');
}
// init session
$this->session->init();
// call didInit event
if (!defined('NO_IMPORTS')) {
EventHandler::fireAction($this, 'didInit');
}
return $this->session;
}