Clear cookies on browser close

How to clear the cookies that has been stored through my asp.net mvc(C#) application, when the user closes the browser?

Is there any option to create a cookie such that it expires once the browser closed?

I need to use cookies, because i will store some of the values to be maintained until the browser is closed.

For example, During sign in i may store the userid in cookie, which i can use for my application processes till the bwoser closes.

Session will expire after some particular time, which i need to overcome with using cookies


Solution 1:

Sessions are usualy used for this. According to Wikipedia, when no expiration date is set, a cookie is cleared when the user closes the browser.

The cookie setter can specify a deletion date, in which case the cookie will be removed on that date. If the cookie setter does not specify a date, the cookie is removed once the user quits his or her browser.