/// <summary> /// Creates a new user sessions and returns the sessionId /// </summary> public async Task <TSessionKey> CreateAsync(TUserKey userId) { await store.RemoveByUserIdAsync(userId); var sessionId = await store.CreateAsync(userId, DateTime.Now.Add(MaximumSessionTimeout)); logger.LogSystemActivity("User Session Created", new { userId, sessionId }); var deletedSessions = await store.ClearSessionsAsync(); if (deletedSessions.Any()) { logger.LogSystemActivity("Expired User Sessions Deleted", deletedSessions.Select(x => x.ToLogMessage())); } return(sessionId); }