Cancelling session when user closes browser window...

Discussion in 'ASP .Net' started by Charlie@NISH, Aug 26, 2005.

  1. Charlie@NISH

    Charlie@NISH Guest

    Hi:

    I would like to clear session when user closes browser window by clicking
    the "x" in upper right hand corner. Since this is a client side event, how
    do I run server code (Session.Abandon()) when user clicks "x"?

    Thanks,
    Charlie
    Charlie@NISH, Aug 26, 2005
    #1
    1. Advertising

  2. Charlie@NISH

    Marina Guest

    The only way would be to trap the onbeforeunload client side event using
    javascript, and then make a call to the server to kill the session. The
    issue here is that this event is always raised, even if the user is just
    browsing to another page on your site - so you need to make sure you only
    kill the session at the right time.

    "Charlie@NISH" <> wrote in message
    news:...
    > Hi:
    >
    > I would like to clear session when user closes browser window by clicking
    > the "x" in upper right hand corner. Since this is a client side event,
    > how do I run server code (Session.Abandon()) when user clicks "x"?
    >
    > Thanks,
    > Charlie
    >
    Marina, Aug 26, 2005
    #2
    1. Advertising

  3. You can never catch this completely. You can use javascript to handle the
    person navigating somewhere, but there isn't any way to catch it when the
    user simply exits their browser.

    "Marina" wrote:

    > The only way would be to trap the onbeforeunload client side event using
    > javascript, and then make a call to the server to kill the session. The
    > issue here is that this event is always raised, even if the user is just
    > browsing to another page on your site - so you need to make sure you only
    > kill the session at the right time.
    >
    > "Charlie@NISH" <> wrote in message
    > news:...
    > > Hi:
    > >
    > > I would like to clear session when user closes browser window by clicking
    > > the "x" in upper right hand corner. Since this is a client side event,
    > > how do I run server code (Session.Abandon()) when user clicks "x"?
    > >
    > > Thanks,
    > > Charlie
    > >

    >
    >
    >
    =?Utf-8?B?d2JyaWFud2hpdGU=?=, Aug 29, 2005
    #3
  4. Charlie@NISH

    Marina Guest

    I believe this event will run even when the browser is closed.

    "wbrianwhite" <> wrote in message
    news:...
    > You can never catch this completely. You can use javascript to handle the
    > person navigating somewhere, but there isn't any way to catch it when the
    > user simply exits their browser.
    >
    > "Marina" wrote:
    >
    >> The only way would be to trap the onbeforeunload client side event using
    >> javascript, and then make a call to the server to kill the session. The
    >> issue here is that this event is always raised, even if the user is just
    >> browsing to another page on your site - so you need to make sure you only
    >> kill the session at the right time.
    >>
    >> "Charlie@NISH" <> wrote in message
    >> news:...
    >> > Hi:
    >> >
    >> > I would like to clear session when user closes browser window by
    >> > clicking
    >> > the "x" in upper right hand corner. Since this is a client side event,
    >> > how do I run server code (Session.Abandon()) when user clicks "x"?
    >> >
    >> > Thanks,
    >> > Charlie
    >> >

    >>
    >>
    >>
    Marina, Aug 30, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. feng
    Replies:
    1
    Views:
    459
    Cowboy \(Gregory A. Beamer\)
    Dec 3, 2003
  2. news.microsoft.com
    Replies:
    5
    Views:
    12,540
    Kalyan Kumar
    Feb 1, 2005
  3. Rafael Chemtob

    session not being killed after user closes browser

    Rafael Chemtob, Feb 11, 2004, in forum: ASP General
    Replies:
    4
    Views:
    355
    Vilmar Braz√£o de Oliveira
    Feb 12, 2004
  4. Luke Matuszewski
    Replies:
    8
    Views:
    621
    Luke Matuszewski
    Dec 2, 2005
  5. karthi
    Replies:
    0
    Views:
    114
    karthi
    Jan 31, 2006
Loading...

Share This Page