diff --git a/modules/saml/lib/IdP/SAML1.php b/modules/saml/lib/IdP/SAML1.php
index ecac85d133c13af95da4acff0dcef55ba56897f2..9ef95b78a5f679eefeced77140d7b3b91231d2c3 100644
--- a/modules/saml/lib/IdP/SAML1.php
+++ b/modules/saml/lib/IdP/SAML1.php
@@ -41,6 +41,9 @@ class sspmod_saml_IdP_SAML1 {
 			'idpEntityID' => $idpMetadata->getString('entityid'),
 			'protocol' => 'saml1',
 		);
+		if (isset($state['saml:AuthnRequestReceivedAt'])) {
+			$statsData['logintime'] = microtime(TRUE) - $state['saml:AuthnRequestReceivedAt'];
+		}
 		SimpleSAML_Stats::log('saml:idp:Response', $statsData);
 
 		/* Generate and send response. */
@@ -122,6 +125,7 @@ class sspmod_saml_IdP_SAML1 {
 
 			'saml:shire' => $shire,
 			'saml:target' => $target,
+			'saml:AuthnRequestReceivedAt' => microtime(TRUE),
 		);
 
 		$idp->handleAuthenticationRequest($state);
diff --git a/modules/saml/lib/IdP/SAML2.php b/modules/saml/lib/IdP/SAML2.php
index 527a640789dc436e2f36c78c4787694d8d6c1546..e48b3eada12cff4175513ce28da4c1abbaacbbdb 100644
--- a/modules/saml/lib/IdP/SAML2.php
+++ b/modules/saml/lib/IdP/SAML2.php
@@ -68,6 +68,9 @@ class sspmod_saml_IdP_SAML2 {
 			'idpEntityID' => $idpMetadata->getString('entityid'),
 			'protocol' => 'saml2',
 		);
+		if (isset($state['saml:AuthnRequestReceivedAt'])) {
+			$statsData['logintime'] = microtime(TRUE) - $state['saml:AuthnRequestReceivedAt'];
+		}
 		SimpleSAML_Stats::log('saml:idp:Response', $statsData);
 
 		/* Send the response. */
@@ -124,6 +127,9 @@ class sspmod_saml_IdP_SAML2 {
 			'protocol' => 'saml2',
 			'error' => $status,
 		);
+		if (isset($state['saml:AuthnRequestReceivedAt'])) {
+			$statsData['logintime'] = microtime(TRUE) - $state['saml:AuthnRequestReceivedAt'];
+		}
 		SimpleSAML_Stats::log('saml:idp:Response:error', $statsData);
 
 		$binding = SAML2_Binding::getBinding($protocolBinding);
@@ -377,6 +383,7 @@ class sspmod_saml_IdP_SAML2 {
 			'saml:NameIDFormat' => $nameIDFormat,
 			'saml:AllowCreate' => $allowCreate,
 			'saml:Extensions' => $extensions,
+			'saml:AuthnRequestReceivedAt' => microtime(TRUE),
 		);
 
 		$idp->handleAuthenticationRequest($state);