diff --git a/lib/SimpleSAML/Auth/Default.php b/lib/SimpleSAML/Auth/Default.php
index f577577fa1a3889957fcb615313ea77f151649bc..3a76906a5d257ba3032095007408370af3601d68 100644
--- a/lib/SimpleSAML/Auth/Default.php
+++ b/lib/SimpleSAML/Auth/Default.php
@@ -98,7 +98,7 @@ class SimpleSAML_Auth_Default {
 		}
 
 		/* Add those that should always be included. */
-		foreach (array('Attributes', 'Expire', 'LogoutState', 'AuthnInstant', 'RememberMe') as $a) {
+		foreach (array('Attributes', 'Expire', 'LogoutState', 'AuthnInstant', 'RememberMe', 'saml:sp:NameID') as $a) {
 			if (isset($state[$a])) {
 				$persistentAuthState[$a] = $state[$a];
 			}
diff --git a/modules/saml/www/sp/saml1-acs.php b/modules/saml/www/sp/saml1-acs.php
index 95cc91b58df646d5916f0de427908a2b1b575b49..b636854f06d193719b127ac4a7df080ed3978560 100644
--- a/modules/saml/www/sp/saml1-acs.php
+++ b/modules/saml/www/sp/saml1-acs.php
@@ -85,6 +85,8 @@ $logoutState = array(
 	);
 $state['LogoutState'] = $logoutState;
 
+$state['saml:sp:NameID'] = $response->getNameID();
+
 $source->handleResponse($state, $responseIssuer, $attributes);
 assert('FALSE');