You are here

public function AnonymousCsrfTokenGenerator::get in Anonymous CSRF Token 2.x

We need to set a value in the session for anonymous users so that the session is persistent across multiple requests.

Overrides CsrfTokenGenerator::get

See also

https://drupal.stackexchange.com/questions/222353

File

src/Access/AnonymousCsrfTokenGenerator.php, line 69

Class

AnonymousCsrfTokenGenerator
Class AnonymousCsrfTokenGenerator.

Namespace

Drupal\anonymous_token\Access

Code

public function get($value = '') {
  if ($this->session
    ->isStarted() === FALSE) {
    $this->session
      ->set('anon_session_id', $this->session
      ->getId());
  }
  return parent::get($value);
}