=== modified file 'includes/form.inc'
--- includes/form.inc	2009-04-27 07:35:48 +0000
+++ includes/form.inc	2009-04-27 15:43:37 +0000
@@ -300,11 +300,11 @@ function drupal_rebuild_form($form_id, &
  * Fetch a form from cache.
  */
 function form_get_cache($form_build_id, &$form_state) {
-  if ($cached = cache_get('form_' . $form_build_id, 'cache_form')) {
+  if ($cached = cache_get(_form_cache_id('form', $form_build_id), 'cache_form')) {
     $form = $cached->data;
     global $user;
     if ((isset($form['#cache_token']) && drupal_valid_token($form['#cache_token'])) || (!isset($form['#cache_token']) && !$user->uid)) {
-      if ($cached = cache_get('storage_' . $form_build_id, 'cache_form')) {
+      if ($cached = cache_get(_form_cache_id('storage', $form_build_id), 'cache_form')) {
         $form_state['storage'] = $cached->data;
       }
       return $form;
@@ -322,13 +322,27 @@ function form_set_cache($form_build_id, 
   if ($user->uid) {
     $form['#cache_token'] = drupal_get_token();
   }
-  cache_set('form_' . $form_build_id, $form, 'cache_form', REQUEST_TIME + $expire);
+  cache_set(_form_cache_id('form', $form_build_id), $form, 'cache_form', REQUEST_TIME + $expire);
   if (!empty($form_state['storage'])) {
-    cache_set('storage_' . $form_build_id, $form_state['storage'], 'cache_form', REQUEST_TIME + $expire);
+    cache_set(_form_cache_id('storage', $form_build_id), $form_state['storage'], 'cache_form', REQUEST_TIME + $expire);
   }
 }
 
 /**
+ * Returns the cache id for form caching.
+ *
+ * @param $prefix
+ *   A prefix for the cache id. Either form or storage.
+ * @param $form_build_id
+ *   A unique string for the form.
+ */
+_function _form_cache_id($prefix, $form_build_id) {
+  global $user;
+  $postfix = ($user->uid || variable_get('cache', CACHE_DISABLED) == CACHE_DISABLED) ? '' : session_id();
+  return "$prefix:$form_build_id:$postfix";
+}
+
+/**
  * Retrieves a form using a form_id, populates it with $form_state['values'],
  * processes it, and returns any validation errors encountered. This
  * function is the programmatic counterpart to drupal_get_form().
@@ -468,6 +482,8 @@ function drupal_retrieve_form($form_id, 
  *   data, is also accumulated here.
  */
 function drupal_process_form($form_id, &$form, &$form_state) {
+  global $user;
+
   $form_state['values'] = array();
 
   // With $_GET, these forms are always submitted if requested.
@@ -503,10 +519,8 @@ function drupal_process_form($form_id, &
       // We'll clear out the cached copies of the form and its stored data
       // here, as we've finished with them. The in-memory copies are still
       // here, though.
-      if (!empty($form_state['values']['form_build_id'])) {
-        cache_clear_all('form_' . $form_state['values']['form_build_id'], 'cache_form');
-        cache_clear_all('storage_' . $form_state['values']['form_build_id'], 'cache_form');
-      }
+      cache_clear_all(_form_cache_id('form', $form_state['values']['form_build_id']), 'cache_form');
+      cache_clear_all(_form_cache_id('storage', $form_state['values']['form_build_id']), 'cache_form');
 
       // If batches were set in the submit handlers, we process them now,
       // possibly ending execution. We make sure we do not react to the batch
@@ -860,8 +874,8 @@ function form_execute_handlers($type, &$
 
   foreach ($handlers as $function) {
     if (drupal_function_exists($function))  {
-      // Check to see if a previous _submit handler has set a batch, but 
-      // make sure we do not react to a batch that is already being processed 
+      // Check to see if a previous _submit handler has set a batch, but
+      // make sure we do not react to a batch that is already being processed
       // (for instance if a batch operation performs a drupal_execute()).
       if ($type == 'submit' && ($batch =& batch_get()) && !isset($batch['current_set'])) {
         // Some previous _submit handler has set a batch. We store the call

