Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    May 2006
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to kill a session when window is closed

    Hi,

    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() {
    Session.Contents.RemoveAll();
    Session.Abandon();
    }

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

    Example:

    <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?
    Thx
    Joe

  • #2
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    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 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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •