Index: program/include/rcube.php
===================================================================
--- program/include/rcube.php	(revision 5d66a4bcf3ad5d584255184776f1f04451c929fc)
+++ program/include/rcube.php	(revision a2f896bdeb2bebd09e85742c2918c79020830212)
@@ -245,5 +245,6 @@
   {
     if (!isset($this->caches[$name])) {
-      $this->caches[$name] = new rcube_cache($type, $_SESSION['user_id'], $name, $ttl, $packed);
+      $userid = $this->get_user_id();
+      $this->caches[$name] = new rcube_cache($type, $userid, $name, $ttl, $packed);
     }
 
@@ -1172,4 +1173,7 @@
             return $this->user->ID;
         }
+        else if (isset($_SESSION['user_id'])) {
+            return $_SESSION['user_id'];
+        }
 
         return null;
