public RestSession GetSession( RestRequest request, out bool newSession) { Cookie sessionCookie = request.Cookies[SESSION_KEY]; string sessionId = ""; RestSession session = null; if (sessionCookie != null) { sessionId = sessionCookie.Value; newSession = false; } else { sessionId = GenerateNewSessionKey(); newSession = true; } if (!m_sessions.TryGetValue(sessionId, out session)) { // TODO: What about expiring old sessions? session = new RestSession(sessionId); m_sessions.Add(sessionId, session); } return session; }
public void FreeSession(RestSession session) { if (m_sessions.ContainsKey(session.SessionID)) { m_sessions.Remove(session.SessionID); } }
public RestSession GetSession( RestRequest request, out bool newSession) { Cookie sessionCookie = request.Cookies[SESSION_KEY]; string sessionId = ""; RestSession session = null; if (sessionCookie != null) { sessionId = sessionCookie.Value; newSession = false; } else { sessionId = GenerateNewSessionKey(); newSession = true; } if (!m_sessions.TryGetValue(sessionId, out session)) { // TODO: What about expiring old sessions? session = new RestSession(sessionId); m_sessions.Add(sessionId, session); } return(session); }
public void AppendSessionIdCookie(RestSession session) { Cookie cookie = m_response.Cookies[RestSessionManager.SESSION_KEY]; if (cookie != null) { cookie.Value = session.SessionID; } else { cookie = new Cookie(RestSessionManager.SESSION_KEY, session.SessionID, "/"); cookie.Expires = DateTime.Now.AddMinutes(RestSessionManager.SESSION_EXPIRATION_MINUTES); m_response.Cookies.Add(cookie); } }