[development] Preserving a dynamic form value without using $_SESSION.

Rajan Agaskar ragaskar at gmail.com
Fri Sep 21 20:57:17 UTC 2007


I'd like to avoid the use $_SESSIONs for storing 'temp' values, but I
need a way to get a dynamic form value through the submit process
without being regenerated.

Right now, here's what is happening:

1. node form is built, $temp_dir value is created.
2. content is created via an AJAX request that is indexed with the $temp_dir
3. node form is submitted (and thus, rebuilt). $temp_dir value is
re-created, now diff. than previous $temp_dir
4. node insert function has 'wrong' $temp_dir value for final
processing of content from step #2.

The following 'works', but doesn't use the drupal FAPI. I'd like to
avoid that if possible:

if ($_POST['temp_dir']) {
  $temp_dir=$_POST['temp_dir'];
}
else {
  $temp_dir = md5(time() . $user -> id);
}

I know there *must* be a way to do this, as seemingly, the form token
has to be generated in this fashion. Any suggestions?

FWIW, due to the manner in which the content is generated, using
sessions is less than desirable (I spent a few days debugging what
ended up being a session race condition, and so I'd prefer to avoid
them altogether at this point).

Thank you for your time

Rajan Agaskar.


More information about the development mailing list