You can try deleting cookies using javascript onunload
event.
<body onunload="deleteAllCookies()">
will call javascript function deleteAllCookies()
on browser tab close, and in the function delete all cookies, will clear authentication
<script>
function deleteAllCookies() {
var cookies = document.cookie.split(";");
for (var i = 0; i < cookies.length; i++) {
var cookie = cookies[i];
var eqPos = cookie.indexOf("=");
var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;
document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT";
}
}
</script>
EDIT
Your question is to clear Authentication when tab closed in a browser. And you are using FormsAuthentication.SetAuthCookie
as shown in question.
That is why i suggested to delete cookies using javascript onunload
event as in my answer . So it will clear Authentication when tab closed in a browser ,
won't consider another tab with different stages of the site (ie answer to the question).
If you want to maintain authentication on another tab with different stage of the site, You have to communicate between browser windows (and tabs too) using cookies .
If you found another tab with same site don't clear cookies. You can do it in the javascript function.
Hope this link will help you. Or try googling.