Drupal valid token

WE HAVE MOVED!

Please visit our new Drupal Website at https://www.xenyo.com我們的新網頁設計公司網頁.

/**
 * create a link with token.
 */
$valid_token= drupal_get_token('checktoken');
$link = l('checktoken', 'Link', array('query' => array('token', $valid_token));
echo $link;
 
modulename_menu() {
  $items['checktoken'] = array(
    'page callback' => 'modulename_checktoken',
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );  
}
 
modulename_checktoken() {
  $token = empty($_GET['token'])?"":$_GET['token'];
  $valid = drupal_valid_token($token, 'checktoken');
  if ($valid) {
    dsm ('This is local site request');
  }
  else {
    dsm ('This is external site request');
    drupal_access_denied();
  }
}
Help Share this Article