diff --git a/www/authmemcookie.php b/www/authmemcookie.php
index a24b0556b71674b674fc6cb919e9b6ffb151bd93..91495913590cb1f451bad07edc668f593737ee51 100644
--- a/www/authmemcookie.php
+++ b/www/authmemcookie.php
@@ -74,11 +74,21 @@ try {
 
     // store the authentication data in the memcache server
     $data = '';
-    foreach ($authData as $n => $v) {
-        if (is_array($v)) {
-            $v = implode(':', $v);
+    foreach ($authData as $name => $values) {
+        if (is_array($values)) {
+            foreach ($values as $i => $value) {
+                if (!is_a($value, 'DOMNodeList')) {
+                    continue;
+                }
+                /* @var \DOMNodeList $value */
+                if ($value->length === 0) {
+                    continue;
+                }
+                $values[$i] = new \SAML2\XML\saml\AttributeValue($value->item(0)->parentNode);
+            }
+            $values = implode(':', $values);
         }
-        $data .= $n.'='.$v."\r\n";
+        $data .= $name.'='.$values."\r\n";
     }
 
     $memcache = $amc->getMemcache();