public WebContext(HttpContext httpcontext) { this.httpcontext = httpcontext; this.requestTime = DateTime.Now; this.design = this.detectDesign(); HttpCookie sessionCookie = this.httprequest.Cookies[Config.instance.CookiesPrefix + "_session"]; if (sessionCookie != null && sessionCookie.Value != null && sessionCookie.Value != "") { try { var session = Session.LoadByKey(sessionCookie.Value); var tmp = session.account; string lastUrl = null; if (this.httprequest.RequestType == "GET") { if (this.design.IsHuman) { lastUrl = this.httprequest.Path; } } session.updateLastActivity(lastUrl); HttpCookie newCookie = this.createCookie(Config.instance.CookiesPrefix + "_session"); newCookie.Value = session.sessionKey; newCookie.Expires = DateTime.Now.AddSeconds(Config.instance.SessionLifetime); this.httpresponse.AppendCookie(newCookie); this.session = session; } catch (NotFoundInDBException) { sessionCookie.Value = ""; sessionCookie.Expires = DateTime.Now.AddDays(-1); this.httpresponse.AppendCookie(sessionCookie); //throw; //TODO: remove me! } } if (this.session != null) { this.userSettings = AccountSettings.LoadByAccount(this.session.account); } else { this.userSettings = new AnonymousUserSettings(null); } }
public WebContext(HttpContext httpcontext) { this.httpcontext = httpcontext; this.requestTime = DateTime.Now; this.design = this.detectDesign(); HttpCookie sessionCookie = this.httprequest.Cookies[Config.instance.CookiesPrefix + "_session"]; if(sessionCookie != null && sessionCookie.Value != null && sessionCookie.Value != "") { try { var session = Session.LoadByKey(sessionCookie.Value); var tmp = session.account; string lastUrl = null; if(this.httprequest.RequestType == "GET") { if(this.design.IsHuman) { lastUrl = this.httprequest.Path; } } session.updateLastActivity(lastUrl); HttpCookie newCookie = this.createCookie(Config.instance.CookiesPrefix + "_session"); newCookie.Value = session.sessionKey; newCookie.Expires = DateTime.Now.AddSeconds(Config.instance.SessionLifetime); this.httpresponse.AppendCookie(newCookie); this.session = session; } catch(NotFoundInDBException) { sessionCookie.Value = ""; sessionCookie.Expires = DateTime.Now.AddDays(-1); this.httpresponse.AppendCookie(sessionCookie); //throw; //TODO: remove me! } } if(this.session != null) { this.userSettings = AccountSettings.LoadByAccount(this.session.account); } else { this.userSettings = new AnonymousUserSettings(null); } }