Set the value of a hidden form component
You should use the presave hook provided by webform instead of adding additional submit handlers to the form.

/**
 * Modify a Webform submission, prior to saving it in the database.
 *
 * @param $node
 *   The Webform node on which this submission was made.
 * @param $submission
 *   The Webform submission that is about to be saved to the database.
 */
function hook_webform_submission_presave($node, &amp;$submission) {
  // Update some component's value before it is saved.
  $component_id = 4;
  $submission-&gt;data[$component_id][0] = 'foo';
}


This is a lot cleaner than adding custom submit handlers to the form (your custom handler is called after the webform submission handler, which can be a big part of the problem).

You have access to the node object in the presave hook so additional checks can be added beforre altering the component.