 			UPDATE prsystem.Users
 			SET ActiveSessionCounter = ActiveSessionCounter - 1
 			WHERE UserName = @UserName	
+
+			INSERT INTO [prsystem].[UserAccessLog]
+           ([UserID]
+           ,[Action]
+           ,[CreatedDateTime]
+           ,[MachineIP])
+			VALUES
+           (@UserID
+           ,'LOGOUT'
+           ,GETDATE()
+           ,NULL)
 		END
 		ELSE
 		BEGIN

					ActiveSessionCounter = ActiveSessionCounter + 1,
					LoginAttemptCount = 0
			WHERE UserName = @UserName
		END
		ELSE IF @Status = 'loginerror'
		BEGIN

	-- interfering with SELECT statements.
		SET NOCOUNT ON;

		DECLARE @ActiveSessionCounter INT,@UserID INT

		select @ActiveSessionCounter = ActiveSessionCounter, @UserID = UserID FROM prsystem.Users
		WHERE UserName = @UserName	

		IF @Status = 'loginsuccess'
