User960609757 posted
Hi,
If you set an expiration date, this will set them to expire on that date, whether the browser is open or closed.
Only non persisted cookies will expire once the browser is closed.
Response.Cookies["test"].Value = "cookie test";
Response.Cookies["test"].Expires = DateTime.MaxValue;
The Expires property of a cookie defaults to DateTime.MinValue (00:00:00.0000000, January 1, 0001). So adding 1 month to that still results in an expired cookie.
If you want to set it to expire 1 month from today, then you can do it like this:
Response.Cookies["test"].Expires = DateTime.Now.AddMonths(1);