You are here

function drupal_valid_token in Drupal 4

Same name and namespace in other branches
  1. 5 includes/common.inc \drupal_valid_token()
  2. 6 includes/common.inc \drupal_valid_token()
  3. 7 includes/common.inc \drupal_valid_token()

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

Parameters

$token: The token to be validated.

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

$skip_anonymous: Set to true to skip token validation for anonymous users.

Return value

True for a valid token, false for an invalid token. When $skip_anonymous is true, the return value will always be true for anonymous users.

Related topics

7 calls to drupal_valid_token()
drupal_validate_form in includes/form.inc
poll_view_voting in modules/poll.module
Generates the voting form for a poll.
update.php in ./update.php
Administrative page for handling updates from one Drupal version to another.
user_admin_access_add in modules/user.module
Menu callback: add an access rule
user_admin_access_edit in modules/user.module
Menu callback: edit an access rule

... See full list

File

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

Code

function drupal_valid_token($token, $value = '', $skip_anonymous = FALSE) {
  global $user;
  return $skip_anonymous && $user->uid == 0 || $token == md5(session_id() . $value . variable_get('drupal_private_key', ''));
}