Self-Explanatory. In PHP, the solution would be to set the cookie expiration to 0; I'm unsure about C# since it requires a DateTime value.
To set a cookie so it expires at the end of the browsing session, simply OMIT the expiration parameter altogether.
Set an expiration date for a cookie This can be done easily by adding expires=expirationDate in UTC separated by semicolon from the name=value, as seen in the following example: document. cookie = "username=Max Brown; expires=Wed, 05 Aug 2020 23:00:00 UTC"; document.
Session cookies expire once you log off or close the browser. They are only stored temporarily and are destroyed after leaving the page.
The Kind property of Expires is used to determine if the cookie is set to DateTimeKind.
The docs for Cookie.Expires call it right out.
Setting the Expires property to MinValue makes this a session Cookie, which is its default value.
cookie.Expires = DateTime.MinValue
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