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

Ensures the private key variable used to generate tokens is set.

Return value

The private key.

6 calls to drupal_get_private_key()
DrupalWebTestCase::drupalGetToken in modules/simpletest/drupal_web_test_case.php
Generate a token for the currently logged in user.
drupal_get_token in includes/common.inc
Generates a token based on $value, the user session, and the private key.
file_managed_file_process in modules/file/file.module
Process function to expand the managed_file element type.
file_managed_file_value in modules/file/file.module
The #value_callback for a managed_file type element.
image_style_path_token in modules/image/image.module
Generates a token to protect an image style derivative.

... See full list

File

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

Code

function drupal_get_private_key() {
  if (!($key = variable_get('drupal_private_key', 0))) {
    $key = drupal_random_key();
    variable_set('drupal_private_key', $key);
  }
  return $key;
}