Page title set from the title callback doesn't change I created a simple download module to redirect a user when they click the download button to another page. Now I need to change the the page title every time a new download is triggered. 

This is my code.

function custom_download_menu() {
  $items['download-code'] = array(
    'title callback' =&gt; 'custom_download_page_title',
    'page callback' =&gt; 'custom_download_view',
    'access arguments' =&gt; array('access content'),
    'access callback' =&gt; TRUE,
  );

  return $items;
}

function custom_download_page_title() {
  if (isset($_POST['title'])) {
    $title = "Downloading " . $_POST['title'] . " Code";
  }
  else {
    $title = "Download Code";
  }

  return $title;
}


But most of the time, the title does not change. It seems that it is using the title that is cached before.

I already added the following code so the page will not be cached:

drupal_add_http_header("Last-Modified", gmdate("D, d M Y H:i:s") . " GMT");
drupal_add_http_header("Cache-Control", "no-store, no-cache, must-revalidate"); // HTTP/1.1
drupal_add_http_header("Cache-Control", "post-check=0, pre-check=0", false);
drupal_add_http_header("Pragma", "no-cache"); // HTTP/1.0
drupal_add_http_header("Expires", "Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past


Am I missing something?

Update:

&lt;form id="form1" name="form1" method="post" action="/download-code"&gt;
    &lt;input type="hidden" name="title" id="title" value="[node:title]" /&gt;
    &lt;input type="hidden" name="download_code" id="download_code" value="[node:field_code_file]" /&gt;
    &lt;input type="hidden" name="uri" id="uri" value="[node:url:relative]" /&gt;
    &lt;input type="submit" class="downloadButton" value="Download Code"&gt;
&lt;/form&gt;
You're missing the title arguments key in hook_menu

e.g:

/**
 * Implements hook_menu
 */
function custom_download_menu() {
  $items = array();

  $items['download-code/%'] = array(
    'title callback' =&gt; 'custom_download_page_title',
    'title arguments' =&gt; array(1), 
    'page callback' =&gt; 'custom_download_view',
    'access callback' =&gt; TRUE,
  );

  return $items;
}

/**
 * hook_menu title callback
 */
function custom_download_page_title($file) {
  if (isset($file) {
    $title = "Downloading " . $file . " Code";
  }
  else {
    $title = "Download Code";
  }
  return $title;
}


If the download link is


  download-code/my-file.txt


The page title should then reflect that.