-3

I want to use drupal_get_token() function in Drupal 8 , but drupal_get_token() is not available anymore in Drupal.

In Drupal 7 I used:

drupal_get_token('arg1')

What is its Drupal 8 equivalent?

closed as off-topic by leymannx, kiamlaluno May 23 at 8:21

  • This question does not appear to be about Drupal within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    I'm voting to close this question as off-topic because the answer can be easily found in the documentation for the function, even if it is in a comment. – kiamlaluno May 23 at 8:21
  • Please don't provide negative voting . For this negative voting drupal.stackexchange block my account – Arif May 23 at 11:00
  • Welcome to Drupal Answers! Users vote basing on the question quality. If you don't want to get down-votes, please avoid asking low-quality questions that don't show any effort in finding the solution. In this case, it was quite easy to get it, as it's shown in the documentation page for drupal_get_token(). – kiamlaluno May 23 at 11:04
  • The answer can be easily found , but the confusion is D7 we can pass argument inside drupal_get_token() , but now with out passing argument I can get token in D8. Two different functionalities here. In D7 drupal_hmac_base64 ( passing value ) for drupal_get_token – Arif May 23 at 11:08
  • I don't see what you find confusing, given it's documented: $token = \Drupal::csrfToken()->get('arg1');. – kiamlaluno May 23 at 11:15
0

In drupal 8 use \Drupal::csrfToken()->get(), or inject the csrf_token service.

  • yes...I am using it – Arif May 23 at 8:02

Not the answer you're looking for? Browse other questions tagged or ask your own question.