SysAdmin.NET 3.0Design / GraphicsArchitectAdvanced.NET 3.5AjaxBeginnerC# 3.0IntermediateDevJavascript.NETASP.NETC#
How to end user session when browser closed
//Using MooToolswindow.addEvent('unload', Cookie.delete.pass('applicationCookie'));//using JavaScript by itself...//http://www.quirksmode.org/js/cookies.htmlvar eraser = function () { eraseCookie('applicationCookie'); };if(window.addEventListener) window.addEventListener('unload',...
//Using MooTools window.addEvent('unload', Cookie.delete.pass('applicationCookie'));
//using JavaScript by itself... //http://www.quirksmode.org/js/cookies.html var eraser = function () { eraseCookie('applicationCookie'); }; if(window.addEventListener) window.addEventListener('unload', eraser, false); else if(window.attachEvent) window.attachEvent('onunload', eraser);Your method removes all other events from unload of the body and is bad practice. In this example, I delete a cookie which is obviously something which can be done even easier but then the same can be said for your article. You could make an
XMLHttpRequest
instead of deleting a cookie and this would be the way to go.