diff --git a/config-templates/authmemcookie.php b/config-templates/authmemcookie.php
index b9f585d29f74539b1daf05fb374b85b79caf06ce..967151248b9cc19140a60d654a808fefeffdd060 100644
--- a/config-templates/authmemcookie.php
+++ b/config-templates/authmemcookie.php
@@ -47,13 +47,14 @@ $config = array(
 	'groups' => NULL,
 
 	/*
-	 * This option contains the hostname of IP address of the memcache server where we should store the
-	 * authentication information. Thos option should match the address part of the
+	 * This option contains the hostnames or IP addresses of the memcache servers where we should store the
+	 * authentication information. Separator is a comma. This option should match the address part of the
 	 * Auth_memCookie_Memcached_AddrPort option in the Auth MemCookie configuration.
 	 *
 	 * Examples:
 	 *  'memcache.host' => '192.168.93.52',
 	 *  'memcache.host' => 'memcache.example.org',
+	 *  'memcache.host' => 'memcache1.example.org,memcache2.example.org'
 	 *
 	 * Default:
 	 *  'memcache.host' => '127.0.0.1',
diff --git a/lib/SimpleSAML/AuthMemCookie.php b/lib/SimpleSAML/AuthMemCookie.php
index 771b737404021b5b07d2a7fa2b192cf6d366d0e8..4a49edf5dcf645b799014e53698392c2429d4c0c 100644
--- a/lib/SimpleSAML/AuthMemCookie.php
+++ b/lib/SimpleSAML/AuthMemCookie.php
@@ -125,7 +125,10 @@ class SimpleSAML_AuthMemCookie {
 		}
 
 		$memcache = new Memcache;
-		$memcache->connect($memcacheHost, $memcachePort);
+
+		foreach (split(",",$memcacheHost) as $memcacheHost) {
+			$memcache->addServer($memcacheHost, $memcachePort);
+		}
 
 		return $memcache;
 	}