Same name and namespace in other branches
  1. 4.6.x includes/common.inc \drupal_get_token()
  2. 4.7.x includes/common.inc \drupal_get_token()
  3. 5.x includes/common.inc \drupal_get_token()
  4. 6.x includes/common.inc \drupal_get_token()

Generates a token based on $value, the user session, and the private key.

Parameters

$value: An additional value to base the token on.

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.

Return value

string A 43-character URL-safe token for validation, based on the user session ID, the hash salt provided from drupal_get_hash_salt(), and the 'drupal_private_key' configuration variable.

See also

drupal_get_hash_salt()

18 calls to drupal_get_token()
aggregator_view in modules/aggregator/aggregator.admin.inc
Displays the aggregator administration page.
batch_process in includes/form.inc
Processes the batch.
comment_links in modules/comment/comment.module
Helper function, build links for an individual comment.
dashboard_admin in modules/dashboard/dashboard.module
Page callback: Displays the dashboard.
drupal_prepare_form in includes/form.inc
Prepares a structured form array.

... See full list

File

includes/common.inc, line 5358
Common functions that many Drupal modules will need to reference.

Code

function drupal_get_token($value = '') {
  return drupal_hmac_base64($value, session_id() . drupal_get_private_key() . drupal_get_hash_salt());
}