View Full Version : How to kill a session when window is closed

01-17-2007, 05:32 PM

On my website I have a section that can open a new window when the users click on it. When the users close the new window, my session variable are still alive. I don't know how to kill it.

I added these lines on my global.asa and the session is still alive.
function Session_OnEnd() {

The global.asa execute when a new window is open.


<a href="java script:void(0)" onclick="window.open('https://secure.drtax.ca/ufileshop/2006/storespec.asp')">2006</a>
<a href="java script:void(0)" onclick="window.open('https://secure.drtax.ca/ufileshop/2005/storespec.asp?taxyear=2005')">2005</a>

By clicking on both links, you will see the same year because the year is a session variable. It's supposed to show 2006 on one page and the other 2005.

How can I fix it?

01-18-2007, 11:14 AM
I'm not entirely clear about your application logic - it sounds a bit like you might need to use two session variables? And in any case, your session shouldn't end if the original browser window is still open.

That said, the issue of Session_OnEnd not firing reliably when the user closes their browser is one I've come up against before, and it's a bit of a pain. You can use Response.IsClientConnected (http://www.devguru.com/technologies/asp/9152.asp) to check if they're still there, but how and when you check is really dependent on your application structure. I've also seen solutions that mirror sessions using the database - it's a bit complex though.