I need to clear all cookies when exiting browser. The purpose of doing this is so that when someone visits this page again after exiting once, the user can have a fresh start. I'm developing my site in asp.net c#
Asked
Active
Viewed 1,144 times
0
-
possible duplicate http://stackoverflow.com/questions/1783302/clear-cookies-on-browser-close – too_cool Jul 30 '15 at 11:33
-
is this a user who wants to programmatically delete all cookies on browser close, or a website for which the cookies are deleted on session end? – user1666620 Jul 30 '15 at 11:51
2 Answers
2
Sounds like you want session cookies. That's pretty simple - just don't specify an expiry date when setting that cookie. This way it will be deleted when the browser closes. Note however that it's when the browser closes, not the tab. Closing the tab without closing the browser will keep the cookies until the browser is closed. If the tab is re-opened without closing the browser, the cookies will still be there.

Vilx-
- 104,512
- 87
- 279
- 422
0
You can achieve this by client side code also.
On page load event, set cookie value with empty string
document.cookie = ' '

Urvesh Purohit
- 20
- 4