The standard way, of course, would be for the cookie to expire when the browser closes and thus log out, but I assume this is not acceptable behavior in your case?
AFAIK, you cannot access the contents of another browser window if this window was not created using Javascript. Since it looks like you are using onUnload handlers in Javascript, you can use the same handlers to keep track of your windows. This would lead to some overhead, although it would not be full (it will not handle browser crashes or if the user navigates from your application, for example).
Pseudo-code: (this should be a combination of server-side code and client-side javascript, as load handlers are processed in Javascript and the session is server-side)
function OnLoad() { if (document.referrer != "{identify your app here}") Session("BrowserWindowsOpen")++; } function OnUnLoad() { if ({your code for if window is closed}) { Session("BrowserWindowsOpen")--; if (Session("BrowserWindowsOpen") == 0 ) performLogOut(); } }
source share