Try answering here: Javascript Link between browser / Windows tabs . Cookies are a common way to do this. Combine them with the onunload event and you can accomplish what you need.
It would be simpler if you just set your cookie to log in as a βsessionβ by setting the lifetime to 0. This is shared between the tabs in most browsers that I used, and cleared when the window closes. The only problem is that Internet Explorer does not try to clear session cookies unless the window is closed, and not when all the tabs of the website are closed.
Reid johnson
source share