Cookies are located on the client machine.
If the user ends their session from the client side you can try using the following javascript.
If the user simply closes their browser, or if the browser closes unexpectedly, I'm not sure the event will fire.
You won't be able to do this effectively from the server side code from a Response because that would require a postback which does not happen if the user navigates away from your page or closes their browser. If you only want to remove the cookies on explicit sign-out, then you can use the other answer from Prasad(Solution 1) which shows how you can do it from the server side.
window.onbeforeunload = function() {
var cookies = document.cookie.split(";");
for (var i = 0; i < cookies.length; i++)
eraseCookie(cookies[i].split("=")[0]);
};
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
function eraseCookie(name) {
createCookie(name,"",-1);
}
Code Reference[^]