Reputation: 9603
Hi i come across very strange Problem in chrome.I have following code for Cookie.
HttpCookie cookie = new HttpCookie("cookie");
cookie.Value = "true";
cookie.Expires.AddDays(30);
Response.Cookies.Add(cookie);
Now above code is not working in chrome while its working well in FF and IE.If i check this cookie in chrome then its there but cookie Expire date is like When the browsing session ends in chrome.
that means if i Close the Browser then the cookie will expire instead of expiring after 30 days.
Upvotes: 4
Views: 4194
Reputation: 7475
You have to use DateTime.Now/DateTime.UtcNow:
HttpCookie cookie = new HttpCookie("cookie");
cookie.Value = "true";
cookie.Expires = DateTime.UtcNow.AddDays(30);
Response.Cookies.Add(cookie);
Upvotes: 4