public Boolean Read(HttpCookie cookie, String key) { UserName = cookie["u"]; Password = cookie["p"]; Time = (cookie["t"] + "").ToInt().ToDateTime(); Expire = (cookie["e"] + "").ToInt().ToDateTime(); Sign = cookie["s"]; var str = $"u={UserName}&p={Password}&t={Time.ToInt()}&e={Expire.ToInt()}&k={key}"; return(str.MD5() == Sign); }
public Boolean Read(IRequestCookieCollection cookie, String cookieKey, String key) { var cookies = cookie[cookieKey]; var cookieDic = cookies.SplitAsDictionary("=", "&"); UserName = cookieDic["u"]; Password = cookieDic["p"]; Time = (cookieDic["t"] + "").ToInt().ToDateTime(); Expire = (cookieDic["e"] + "").ToInt().ToDateTime(); Sign = cookieDic["s"]; var str = $"u={UserName}&p={Password}&t={Time.ToInt()}&e={Expire.ToInt()}&k={key}"; return(str.MD5() == Sign); }
public void Write(IResponseCookies cookie, String cookieKey, String key) { var cookieOptions = new CookieOptions { HttpOnly = true, Expires = Expire }; var str = $"u={UserName}&p={Password}&t={Time.ToInt()}&e={Expire.ToInt()}&k={key}"; Sign = str.MD5(); str = str + "&s=" + Sign; cookie.Append(cookieKey, str, cookieOptions); }
public void Write(HttpCookie cookie, String key) { //cookie.HttpOnly = true; cookie["u"] = UserName; cookie["p"] = Password; var dt = Time; cookie["t"] = dt.ToInt() + ""; var exp = Expire; cookie.Expires = exp; cookie["e"] = exp.ToInt() + ""; var str = $"u={UserName}&p={Password}&t={Time.ToInt()}&e={Expire.ToInt()}&k={key}"; Sign = str.MD5(); cookie["s"] = Sign; }