Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Request.php

function Request::getSession

Gets the Session.

Throws

SessionNotFoundException When session is not set properly

File

vendor/symfony/http-foundation/Request.php, line 678

Class

Request
Request represents an HTTP request.

Namespace

Symfony\Component\HttpFoundation

Code

public function getSession() : SessionInterface {
    $session = $this->session;
    if (!$session instanceof SessionInterface && null !== $session) {
        $this->setSession($session = $session());
    }
    if (null === $session) {
        throw new SessionNotFoundException('Session has not been set.');
    }
    return $session;
}
RSS feed
Powered by Drupal