C#.Net在关闭网页前调用Js来清空Cookie
window.onbeforeunload = function () { deleteCookie("CookieName"); } //删除清空cookies function deleteCookie(name) { var exp = new Date(); exp.setTime(exp.getTime() - 1); var cval = getMyCookies(name); if (cval != null) document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString(); } function getMyCookies(name) { var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)"); if (arr = document.cookie.match(reg)) return (arr[2]); else return null; }