Documentation

getContext

\Bitrix\Main\Context public
\Bitrix\Main\Application::getContext(
);

Non-static method returns the current connection context.

No parameters

Examples

Reinitialization, if something needs to be changed in POST, $_GET

$httpApp = \Bitrix\Main\Application::getInstance();
$context = $httpApp->getContext();

//set cookies, if required
$context->getResponse()->flush('');

$server = new Server($_SERVER);
$request = new HttpRequest($server, $_GET, $_POST, $_FILES, $_COOKIE);

$response = new HttpResponse($context);
$context->initialize($request, $response, $server, array('env' => $_ENV));
$httpApp->setContext($context);


© «Bitrix24», 2001-2024
Up