asp.net - cookie does not adding -


Adding a cookie to the server:
  Private Zero addcookie (int id) {Html> 

HTTP cookie cookie = new HTTP ("wmpayment"); Cookie Value = id.ToString (); Cookie.Expires = DateTime.Now.AddDays (2); This.ControllerContext.HttpContext.Response.Cookies.Add (cookie); }

But when I read cookies from the request - cookie Expire equal date 01.01.0001

  Public Fixed Ent WMPendingOrder {get {var cookie = HttpContext. Current.request.cookies ["wmpayment"]; Int id = 0; Date timeout; If (cookie! = Null) {dateTime.TryParse (cookie.experience.tostring (), XP out); If (datetime.now & lt; exp) int.TryParse (cookie.Value, ID outside); } Return ID; }}   

Log in: COOKIE.Name: wmpayment cookie.value: 0 cookie.express: 01.01.0001 0:00:00 I do not understand That problem has been

So basically there are two pieces of information that you need to continue. About ID and an expiration date how to store expiry date in a different cookie:

  Private Zero addcookie (int id) {Http cookie cookie = new HTTP cookie ("wmpayment"); Cookie Value = id.ToString (); Cookie.Expires = DateTime.Now.AddDays (2); This.ControllerContext.HttpContext.Response.Cookies.Add (cookie); HTTP Cookie Cookies = New HTTPS ("wmpaymentexpire"); Cookie.value = DateTime.Now Update Date (2) .Ostring (); Cookie.Expires = DateTime.Now.AddDays (2); This.ControllerContext.HttpContext.Response.Cookies.Add (cookie); }   

You read the value of the cookie wmpaymentexpire to check the expiration date for the cookie wmpayment .

Comments