protected void Page_Load(object sender, EventArgs e) { if (Request.UrlReferrer != null) { if (Request.UrlReferrer.ToString().ToLower().Contains("checkin.aspx")) { checkInDay = true; } } if (!IsPostBack) { InitializeForm(); HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName]; HttpCookie macCookie = Request.Cookies[ConfigurationManager.ConnectionStrings["MacCookieName"].ConnectionString]; HttpCookie ipCookie = Request.Cookies[ConfigurationManager.ConnectionStrings["IpCookieName"].ConnectionString]; if (authCookie != null && macCookie != null && ipCookie != null) { // Get the Form Authentcation cookie. FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value); // Check to see if Authentication cookie has been exired or not. if (!ticket.Expired) { cookies decryptCookie = new cookies(); if (decryptCookie.Unprotect(macCookie.Value, ConfigurationManager.ConnectionStrings["MacCookieName"].ConnectionString) == decryptCookie.MacAddress && decryptCookie.Unprotect(ipCookie.Value, ConfigurationManager.ConnectionStrings["IpCookieName"].ConnectionString) == decryptCookie.IPAddress) { SessionVariables.UserName = ticket.Name; Response.Redirect("/Default.aspx"); } } } } ClientScript.RegisterStartupScript(GetType(), "Javascript", "javascript:disableSubmit(); ", true); }
protected void Page_Load(object sender, EventArgs e) { if (Request.UrlReferrer != null) { if (!Request.UrlReferrer.ToString().Contains("Account/Login.aspx")) { redirect = Request.UrlReferrer.ToString(); } } if (!IsPostBack) { ErrorString = null; HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName]; HttpCookie macCookie = Request.Cookies[ConfigurationManager.ConnectionStrings["MacCookieName"].ConnectionString]; HttpCookie ipCookie = Request.Cookies[ConfigurationManager.ConnectionStrings["IpCookieName"].ConnectionString]; if (authCookie != null && macCookie != null && ipCookie != null) { // Get the Form Authentcation cookie. FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value); // Check to see if Authentication cookie has been exired or not. if (!ticket.Expired) { cookies decryptCookie = new cookies(); if (decryptCookie.Unprotect(macCookie.Value, ConfigurationManager.ConnectionStrings["MacCookieName"].ConnectionString) == decryptCookie.MacAddress && decryptCookie.Unprotect(ipCookie.Value, ConfigurationManager.ConnectionStrings["IpCookieName"].ConnectionString) == decryptCookie.IPAddress) { SessionVariables.UserName = ticket.Name; if (String.IsNullOrEmpty(redirect)) { Response.Redirect("/Default.aspx"); } else if (redirect.Contains("/AccountManagement.aspx")) { Response.Redirect("/Default.aspx"); } else { Response.Redirect(redirect); } } } } } else { } }
public bool UserCookiesExists() { HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName]; HttpCookie macCookie = Request.Cookies[ConfigurationManager.ConnectionStrings["MacCookieName"].ConnectionString]; HttpCookie ipCookie = Request.Cookies[ConfigurationManager.ConnectionStrings["IpCookieName"].ConnectionString]; if (authCookie != null && macCookie != null && ipCookie != null) { // Get the Form Authentcation cookie. FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value); // Check to see if Authentication cookie has been exired or not. if (!ticket.Expired) { cookies decryptCookie = new cookies(); if (decryptCookie.Unprotect(macCookie.Value, ConfigurationManager.ConnectionStrings["MacCookieName"].ConnectionString) == decryptCookie.MacAddress && decryptCookie.Unprotect(ipCookie.Value, ConfigurationManager.ConnectionStrings["IpCookieName"].ConnectionString) == decryptCookie.IPAddress) { return(true); } } } return(false); }