This is most likely a drupal problem rather than a ctools_object_cache problem, but since there are no issues on the topic, I'll post here for others future reference.

I have a site which toggles between HTTPS and HTTP. Logins / Admin & E-Commerce are HTTPS, everything else is HTTP.

I have a workflow, which allows an anonymous user to create a node, then after that's done, it's stored in ctools_object_cache. This is done under HTTP.

After the node form is filled out, and the node is saved in ctools_object_cache, they are redirected to signup which is HTTPS. I pull some values from the node, to assist in pre-filling fields on the signup form.

This used to work under only HTTP, but I've noticed that when I store something in ctools_object_cache (not using a custom session variable), it is no longer available under HTTPS due to having a different session id.

As mentioned, this is a Drupal quirk and not really a ctools issue, but I figured I'd post this problem for future reference.

Comments

j0rd’s picture

I've implemented a wrapper class to "resolve" this issue. Ideally though, ctools_object_cache table would hold both ssid and sid sessions to mitigate this problem.

/**
 * Get the current data from the cache. 
 */
function mymodule_cache_get_wrapper($type, $id) {
  ctools_include('object-cache');
  $data = ctools_object_cache_get($type, $id);
  if(empty($data)) {
    $other_session_id = '';
    if(!empty($_SERVER['HTTPS'])) {
      $other_session_id = db_query("SELECT sid FROM {sessions} WHERE ssid=:session", array(
        ':session' => session_id()
      ))->fetchField();
    }
    else {
      $other_session_id = db_query("SELECT ssid FROM {sessions} WHERE sid=:session", array(
        ':session' => session_id()
      ))->fetchField();
    } 
    if(!empty($other_session_id)) {
      $data = ctools_object_cache_get($type, $id, FALSE, $other_session_id); 
    }
  }
  return ($data) ? $data : NULL;
} 

EternalLight’s picture

Issue summary: View changes

#1 worked for me, thank you.