Form API-passing on the NID in a hidden field?
Just save the node ID in $_SESSION. 

Using variable_set() has another effect, apart saving a value that is valid for all the users: It clears the cache Drupal uses for the Drupal variables, with the effect they are reloaded from the database the next time Drupal bootstraps. Compare the code used by variable_set() and variable_initialize(). (Similar code is executed by Drupal 6.)

  db_merge('variable')-&gt;key(array('name' =&gt; $name))-&gt;fields(array('value' =&gt; serialize($value)))-&gt;execute();

  cache_clear_all('variables', 'cache_bootstrap');

  $conf[$name] = $value;




  // NOTE: caching the variables improves performance by 20% when serving
  // cached pages.
  if ($cached = cache_get('variables', 'cache_bootstrap')) {
    $variables = $cached-&gt;data;
  }
  else {
    // Cache miss. Avoid a stampede.
    $name = 'variable_init';
    if (!lock_acquire($name, 1)) {
      // Another request is building the variable cache.
      // Wait, then re-run this function.
      lock_wait($name);
      return variable_initialize($conf);
    }
    else {
      // Proceed with variable rebuild.
      $variables = array_map('unserialize', db_query('SELECT name, value FROM {variable}')-&gt;fetchAllKeyed());
      cache_set('variables', $variables, 'cache_bootstrap');
      lock_release($name);
    }
  }

  foreach ($conf as $name =&gt; $value) {
    $variables[$name] = $value;
  }


As for an example of how to use $_SESSION in a form, see node_filter_form(), the form builder function that handles the form that allows to filter nodes in admin/content/node. 



  $session = isset($_SESSION['node_overview_filter']) ? $_SESSION['node_overview_filter'] : array();
  $filters = node_filters();

  $i = 0;
  $form['filters'] = array(
    '#type' =&gt; 'fieldset',
    '#title' =&gt; t('Show only items where'),
    '#theme' =&gt; 'exposed_filters__node',
  );
  foreach ($session as $filter) {
    list($type, $value) = $filter;
    if ($type == 'term') {
      // Load term name from DB rather than search and parse options array.
      $value = module_invoke('taxonomy', 'term_load', $value);
      $value = $value-&gt;name;
    }
    elseif ($type == 'language') {
      $value = $value == LANGUAGE_NONE ? t('Language neutral') : module_invoke('locale', 'language_name', $value);
    }
    else {
      $value = $filters[$type]['options'][$value];
    }
    $t_args = array(
      '%property' =&gt; $filters[$type]['title'],
      '%value' =&gt; $value,
    );
    if ($i++) {
      $form['filters']['current'][] = array('#markup' =&gt; t('and where %property is %value', $t_args));
    }
    else {
      $form['filters']['current'][] = array('#markup' =&gt; t('where %property is %value', $t_args));
    }
    if (in_array($type, array('type', 'language'))) {
      // Remove the option if it is already being filtered on.
      unset($filters[$type]);
    }
  }

  $form['filters']['status'] = array(
    '#type' =&gt; 'container',
    '#attributes' =&gt; array('class' =&gt; array('clearfix')),
    '#prefix' =&gt; ($i ? '&lt;div class="additional-filters"&gt;' . t('and where') . '&lt;/div&gt;' : ''),
  );
  $form['filters']['status']['filters'] = array(
    '#type' =&gt; 'container',
    '#attributes' =&gt; array('class' =&gt; array('filters')),
  );
  foreach ($filters as $key =&gt; $filter) {
    $form['filters']['status']['filters'][$key] = array(
      '#type' =&gt; 'select',
      '#options' =&gt; $filter['options'],
      '#title' =&gt; $filter['title'],
      '#default_value' =&gt; '[any]',
    );
  }


Its form submission handler sets $_SESSION with the values entered by the user.

  // Apply every filter that has a choice selected other than 'any'.
  foreach ($filters as $filter =&gt; $options) {
    if (isset($form_state['values'][$filter]) &amp;&amp; $form_state['values'][$filter] != '[any]') {
      // Flatten the options array to accommodate hierarchical/nested options.
      $flat_options = form_options_flatten($filters[$filter]['options']);
      // Only accept valid selections offered on the dropdown, block bad input.
      if (isset($flat_options[$form_state['values'][$filter]])) {
        $_SESSION['node_overview_filter'][] = array($filter, $form_state['values'][$filter]);
      }
    }
  }