public static Drupal::csrfToken()
Returns the CSRF token manager service.
The generated token is based on the session ID of the current user. Normally, anonymous users do not have a session, so the generated token will be different on every page request. To generate a token for users without a session, manually start a session prior to calling this function.
\Drupal\Core\Access\CsrfTokenGenerator The CSRF token manager.
\Drupal\Core\Session\SessionManager::start()
public static function csrfToken() { return static::getContainer()->get('csrf_token'); }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal.php/function/Drupal::csrfToken/8.1.x