Session.php in Drupal 9
File
core/lib/Drupal/Core/StackMiddleware/Session.php
View source
<?php
namespace Drupal\Core\StackMiddleware;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\HttpKernelInterface;
class Session implements HttpKernelInterface {
use ContainerAwareTrait;
protected $httpKernel;
protected $sessionServiceName;
public function __construct(HttpKernelInterface $http_kernel, $service_name = 'session') {
$this->httpKernel = $http_kernel;
$this->sessionServiceName = $service_name;
}
public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE) {
if ($type === self::MASTER_REQUEST && PHP_SAPI !== 'cli') {
$session = $this->container
->get($this->sessionServiceName);
$session
->start();
$request
->setSession($session);
}
$result = $this->httpKernel
->handle($request, $type, $catch);
if ($type === self::MASTER_REQUEST && $request
->hasSession()) {
$request
->getSession()
->save();
}
return $result;
}
}
Classes
Name |
Description |
Session |
Wrap session logic around a HTTP request. |