protected override void AttachChildControls() { this.sessionId = this.Page.Request.QueryString["sessionId"]; if (string.IsNullOrEmpty(this.sessionId)) { this.Page.Response.Redirect("/Vshop/Default.aspx"); } else { MemberInfo member = MemberProcessor.GetMember(this.sessionId); if ((member == null) || (member.SessionEndTime < DateTime.Now)) { this.Page.Response.Redirect("/Vshop/Default.aspx"); } else { MemberInfo currentMember = MemberProcessor.GetCurrentMember(); if ((currentMember != null) && (string.IsNullOrEmpty(currentMember.OpenId) && (currentMember.UserId != member.UserId))) { currentMember.OpenId = member.OpenId; MemberProcessor.UpdateMember(currentMember); MemberProcessor.Delete(member.UserId); member = currentMember; } HttpCookie cookie = new HttpCookie("Vshop-Member") { Value = member.UserId.ToString(), Expires = DateTime.Now.AddYears(10) }; HttpContext.Current.Response.Cookies.Add(cookie); MemberProcessor.SetMemberSessionId(member.SessionId, DateTime.Now, member.OpenId); if (!(string.IsNullOrEmpty(member.UserName) || !(member.UserName != member.OpenId))) { this.Page.Response.Redirect("/Vshop/Default.aspx"); } else { PageTitle.AddSiteNameTitle("登录"); } } } }
protected override void AttachChildControls() { this.sessionId = this.Page.Request.QueryString["sessionId"]; if (string.IsNullOrEmpty(this.sessionId)) { this.Page.Response.Redirect("Default.aspx"); } else { MemberInfo memberInfo = MemberProcessor.GetMember(this.sessionId); if (memberInfo == null || memberInfo.SessionEndTime < System.DateTime.Now) { this.Page.Response.Redirect("Default.aspx"); } else { MemberInfo currentMember = MemberProcessor.GetCurrentMember(); if (currentMember != null) { if (string.IsNullOrEmpty(currentMember.OpenId) && currentMember.UserId != memberInfo.UserId) { currentMember.OpenId = memberInfo.OpenId; MemberProcessor.UpdateMember(currentMember); MemberProcessor.Delete(memberInfo.UserId); memberInfo = currentMember; } } base.setLogin(memberInfo.UserId); MemberProcessor.SetMemberSessionId(memberInfo.SessionId, System.DateTime.Now, memberInfo.OpenId); if (!string.IsNullOrEmpty(memberInfo.UserName) && memberInfo.UserName != memberInfo.OpenId) { this.Page.Response.Redirect("Default.aspx"); } else { PageTitle.AddSiteNameTitle("登录"); } } } }