You are here

protected function FlagService::ensureSession in Flag 8.4

Makes sure session is started.

1 call to FlagService::ensureSession()
FlagService::flag in src/FlagService.php
Flags the given entity given the flag and entity objects.

File

src/FlagService.php, line 95

Class

FlagService
Flag service.

Namespace

Drupal\flag

Code

protected function ensureSession() {
  if ($this->currentUser
    ->isAnonymous() && !$this->sessionManager
    ->isStarted()) {

    // Add something to $_SESSION so the session ID will persist.
    // TODO: Replace this with something cleaner once core provides it.
    // See https://www.drupal.org/node/2865991.
    $_SESSION['flag'] = TRUE;
    $this->sessionManager
      ->start();
  }
}