protected void Session_Start(object sender, EventArgs e) { var clientInfo = WebControlManager.GetClientInfo(); var sessionInfo = new SessionProperties(true, clientInfo); //get the default tournament using (var db = Global.GetConnection()) { var tours = from t in db.Inti_Tournament select t; foreach (var tour in tours.OrderByDescending(tStart => tStart.StartRegistration).ToList()) { sessionInfo.SelectedTournament = tour; sessionInfo.DefaultTournament = tour; break; } } if (Request.Cookies != null) { if (Request.Cookies.Get("SignMeIn") != null) { //automatic sign in sessionInfo.UserGuid = new Guid(Request.Cookies["SignMeIn"].Value); //set user guid var user = new UserManagement(Global.ConnectionString, sessionInfo).GetUserByGuid(sessionInfo.UserGuid); sessionInfo.UserName = user.UserName; //set footer text sessionInfo.FooterText = String.Format("Inloggad som {0} {1}", user.FirstName, user.LastName); //set permissions sessionInfo.Permissions = new UserManagement(Global.ConnectionString, sessionInfo).GetUserPermissions(sessionInfo.UserName); } } //set as not signed in HttpContext.Current.Session.RemoveAll(); HttpContext.Current.Session.Add("sessionProps", sessionInfo); }