/// <summary> /// Loads a session's data based upon the existing session ID passed back from the user in a cookie. /// This is version ONLY works for Websites where the HttpContext.Current is available. For applications that do not have the HttpContext.Current available, use <see cref="M:LoadSession(string sessionId)"/> instead /// </summary> public static void LoadSession() { if (HttpContext.Current != null && HttpContext.Current.Request.Cookies[WcfUserSessionBehaviour.SecurityStringCookieName] != null) { string sessionId = HttpContext.Current.Request.Cookies[WcfUserSessionBehaviour.SecurityStringCookieName].Value; WcfUserClientSession.LoadSession(sessionId); } }
/// <summary> /// Loads a session's data based upon the given Session ID. /// Websites and applications with the HttPContext.Current available can use <see cref="M:LoadSession()"/> instead /// </summary> /// <param name="sessionId">The Id of the session to load</param> public static void LoadSession(string sessionId) { ClientSessionData data = null; if ((data = WcfUserClientSession.SessionStore.GetSessionData(sessionId)) != null) { WcfUserClientSession.SetClientSession(data.UserSessionConfiguration); } }
/// <summary> /// Sets the client session to be a session with the given User Session Configuration /// </summary> /// <param name="config">The user session configuration for the current client session</param> public static void SetClientSession(UserSessionConfiguration config) { if (config == null || string.IsNullOrWhiteSpace(config.SessionId)) { return; } ClientSessionData data = new ClientSessionData() { LastTimeUpdated = DateTime.Now, UserSessionConfiguration = config }; WcfUserClientSession.SessionStore.StoreSession(config.SessionId, data); WcfUserClientSession.Current = new WcfUserClientSession(config); }