I want my cookie to disappear when the user closes their brower-- I've already set some promising looking properties, but my cookies pop back to live even after closing the entire browser.
HttpCookie cookie = new HttpCookie("mycookie", "abc");
cookie.HttpOnly = true; //Seems to only affect script access
cookie.Secure = true; //Seems to affect only https transport
What property or method call am I missing to achieve an in memory cookie?
Some cookies are allocated to your PC only for the duration of your visit to a website, and these are called session based cookies. These automatically expire when you close down your browser. Another type of cookie would remain on your PC for a period of time. These are known as “persistent” cookies.
Both persistent and session cookies store a user's information, settings, preferences, or sign-on credentials, when the user consents to such information being stored. However, persistent cookies retain this information even after users close their browsers.
Session cookies do not retain any information on your device or send information from your device. These cookies are deleted when the session expires or is terminated when the browser window is closed. Persistent cookies remain on the device until you erase them or they expire.
cookie.Expires = DateTime.MinValue;
this cookie will expire, as soon as the browser is closed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With