• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/session/session.php
  • Класс: BitrixMainSessionSession
  • Вызов: Session::start
public function start(): bool
{
	if ($this->isStarted())
	{
		return true;
	}

	if ($this->isActive())
	{
		throw new RuntimeException('Could not start session by PHP because session is active.');
	}

	if ($this->isHeadersSent($file, $line))
	{
		throw new RuntimeException(
			"Could not start session because headers have already been sent. "{$file}":{$line}."
		);
	}

	$this->debug('Session tries to start at');
	$this->detectFirstUsage();

	try
	{
		$this->applySessionStartIniSettings($this->getSessionStartOptions());
		if (!session_start() && !$this->ignoringSessionStartErrors)
		{
			throw new RuntimeException('Could not start session by PHP.');
		}
	}
	catch (Error $error)
	{
		if ($this->shouldLogError($error))
		{
			$this->writeToLogError($error);
		}

		if (!$this->ignoringSessionStartErrors)
		{
			throw $error->getPrevious() ?: $error;
		}
	}
	$this->debug('Session started at');

	$this->sessionData = &$_SESSION;
	$this->started = true;

	if ($this->has('destroyed'))
	{
		//todo 100? why?
		if ($this->get('destroyed') < time() - 100)
		{
			$this->clear();
		}
		else
		{
			$newSessionId = $this->get('newSid');
			$this->save();

			$this->setId($newSessionId);

			return $this->start();
		}
	}

	return true;
}