public void AddSession(Session session, string sessionId) { lock (syncRoot) { if (!serverSessions.ContainsKey(sessionId)) { serverSessions.Add(sessionId, session); sessionObjects.Add(sessionId, new Dictionary<string, object>()); } else { // Session already added. Is this an error } } }
public void NewSession(string userId) { // NOTE: THIS IS VERY DANGEROUS SECURITY RISK !!! ONLY USED FOR THIS DUMMY DEMO Session session = ServerContext.Instance.GetSessionByUserId(userId); if (session == null) { HorusSession horusSession = HorusSession.CreateLocalSession(); string sessionId = Guid.NewGuid().ToString(); session = new Session() { SessionId = sessionId, LocalHorusSession = horusSession, UserId = userId, SessionExpiryTime = DateTime.UtcNow.AddHours(1) }; ServerContext.Instance.AddSession(session, sessionId); } Response.Write(session.SessionId); }