diff --git a/lib/SimpleSAML/Store/Memcache.php b/lib/SimpleSAML/Store/Memcache.php
index ccccda0a1c3492c6ff8620615b9039eec134d13d..15660acfbec3b474992e92fbfe0c82296ed79b76 100644
--- a/lib/SimpleSAML/Store/Memcache.php
+++ b/lib/SimpleSAML/Store/Memcache.php
@@ -43,6 +43,10 @@ class SimpleSAML_Store_Memcache extends SimpleSAML_Store {
 		assert('is_string($key)');
 		assert('is_null($expire) || (is_int($expire) && $expire > 2592000)');
 
+		if ($expire === NULL) {
+			$expire = 0;
+		}
+
 		SimpleSAML_Memcache::set('simpleSAMLphp.' . $type . '.' . $key, $value, $expire);
 	}