How do I pass the nid of the current node to the first step multistep modal form? I am using the ctools plumbing to create a nodal form. This is what the relevant part of my code now looks like:

/**
 * Implements hook_entity_view_alter().
 */
function mymodule_entity_view_alter(&amp;$build) {
  $nid = $build['body']['#object']-&gt;nid;

  // Set up ctools etc. to use modal omitted for brevity.

  $build['links']['popup']['#links']['mylink'] = array(
    'title' =&gt; 'show popup',
    'href' =&gt; 'mymodule/nojs/modals',
    'html' =&gt; TRUE,
    'attributes' =&gt; array(
      'class' =&gt; array(
        'ctools-use-modal', 
        'ctools-modal-mymodule-style',
      ),
    ),
  );
}


The nid of the node this link will be attached to is known at this point. (See first line of function.)

However, my code need to be aware of the nid at each step in the modal form.

I think it possible to do this by stashing it in a session cookie, but I would like to avoid using cookies, if possible.

Is there another way to do this?
I think the simplest way would be to change your path to incorporate the nid, e.g.

function MYMODULE_menu() {
  $items['mymodule/%ctools_js/modals/%node'] = array(
    'title' =&gt; 'Title',
    'page callback' =&gt; 'MYMODULE_callback',
    'page arguments' =&gt; array(1, 3),
    ...
  );

  return $items;
}


Change the path in the link

$build['links']['popup']['#links']['mylink'] = array(
  'title' =&gt; 'show popup',
  'href' =&gt; 'mymodule/nojs/modals/' . $nid,
  'html' =&gt; TRUE,
  'attributes' =&gt; array(
    'class' =&gt; array(
      'ctools-use-modal', 
      'ctools-modal-mymodule-style',
    ),
  ),
);


And in your callback:

function MYMODULE_callback($js, $node) {
  // $node is fully loaded, continue as normal...
}