Close User Session

Discussion in 'ASP .Net' started by Laurahn, Mar 14, 2007.

  1. Laurahn

    Laurahn Guest

    How can i configure my application for closing the session ? How can i use
    the session end for closing the session ?
     
    Laurahn, Mar 14, 2007
    #1
    1. Advertising

  2. Session end is only the event fired when a session is ended. To end the
    user's session you would use Session.Abandon() I believe. It will
    automatically close the session after 20 minutes of inactivity anyways, and
    unload the application itself after the last session is closed.


    --
    Hope this helps,
    Mark Fitzpatrick
    Former Microsoft FrontPage MVP 199?-2006

    "Laurahn" <> wrote in message
    news:...
    > How can i configure my application for closing the session ? How can i use
    > the session end for closing the session ?
    >
     
    Mark Fitzpatrick, Mar 14, 2007
    #2
    1. Advertising

  3. On Mar 14, 11:17 pm, "Laurahn" <> wrote:
    > How can i configure my application for closing the session ? How can i use
    > the session end for closing the session ?


    Configure a timeout or call Session.Abandon()
     
    Alexey Smirnov, Mar 14, 2007
    #3
  4. Laurahn

    Laurahn Guest

    Thanks Mark.

    But, i want to know what code I have to put into my app for that hapends.

    Can i use a button?

    i've read about put some code on Global.asax
     
    Laurahn, Mar 14, 2007
    #4
  5. Laurahn

    Laurahn Guest

    How i Configure a timeout?

    Where have I to call Session.Abandon()?
     
    Laurahn, Mar 14, 2007
    #5
  6. Laurahn

    Mark Rae Guest

    "Laurahn" <> wrote in message
    news:...

    > But, i want to know what code I have to put into my app for that hapends.
    >
    > Can i use a button?
    >
    > i've read about put some code on Global.asax


    In Global.asax, you have an event called Session_End - this is the event
    which fires (so long as your Session is InProc) when the Session ends.

    Under normal circumstances, the Session ends for two reasons:

    1) it has timed out automatically, by default after 20 minutes of
    inactivity, though this figure can be changed

    2) it has been ended explicitly ("torn down", to use the jargon)

    You may be familiar with logging out of your on-line banking application by
    clicking a "Logout" button or whatever - it is the code behind such a button
    where you would place the Session.Abandon() code.
     
    Mark Rae, Mar 14, 2007
    #6
  7. Laurahn

    Scott M. Guest

    Make a button on your web page. Give it text of "Log out". In its
    server-side click event handler, simply write: Session.Abandon()

    And/Or in your Web.Config file, find the section that is already there about
    the session timeout and change the time from 20 minutes to something else.



    "Laurahn" <> wrote in message
    news:u$e%...
    > How i Configure a timeout?
    >
    > Where have I to call Session.Abandon()?
    >
    >
     
    Scott M., Mar 15, 2007
    #7
  8. Laurahn

    Scott M. Guest

    You response doesn't really address the question. The Session_End event
    handler is of no use when you are trying to end the session, only after (or
    as) the session has ended.

    I have been working with sessions for many, many years and you are the first
    person to use the "torn down" jargon you speak of that I've ever heard.
    It's not a good idea to introduce jargon that is not widely used.


    "Mark Rae" <> wrote in message
    news:...
    > "Laurahn" <> wrote in message
    > news:...
    >
    >> But, i want to know what code I have to put into my app for that hapends.
    >>
    >> Can i use a button?
    >>
    >> i've read about put some code on Global.asax

    >
    > In Global.asax, you have an event called Session_End - this is the event
    > which fires (so long as your Session is InProc) when the Session ends.
    >
    > Under normal circumstances, the Session ends for two reasons:
    >
    > 1) it has timed out automatically, by default after 20 minutes of
    > inactivity, though this figure can be changed
    >
    > 2) it has been ended explicitly ("torn down", to use the jargon)
    >
    > You may be familiar with logging out of your on-line banking application
    > by clicking a "Logout" button or whatever - it is the code behind such a
    > button where you would place the Session.Abandon() code.
    >
     
    Scott M., Mar 15, 2007
    #8
  9. Laurahn

    Scott M. Guest

    I don't believe the application is unloaded after the last session is
    unloaded. I belive the application sits idle until it crashes or is taken
    off-line, but I don't believe it just ends itself.


    "Mark Fitzpatrick" <> wrote in message
    news:...
    > Session end is only the event fired when a session is ended. To end the
    > user's session you would use Session.Abandon() I believe. It will
    > automatically close the session after 20 minutes of inactivity anyways,
    > and unload the application itself after the last session is closed.
    >
    >
    > --
    > Hope this helps,
    > Mark Fitzpatrick
    > Former Microsoft FrontPage MVP 199?-2006
    >
    > "Laurahn" <> wrote in message
    > news:...
    >> How can i configure my application for closing the session ? How can i
    >> use the session end for closing the session ?
    >>

    >
    >
     
    Scott M., Mar 15, 2007
    #9
  10. Laurahn

    Mark Rae Guest

    "Scott M." <> wrote in message
    news:...

    > Make a button on your web page. Give it text of "Log out". In its
    > server-side click event handler, simply write: Session.Abandon()


    Wish I'd thought of that... ;-)
     
    Mark Rae, Mar 15, 2007
    #10
  11. Laurahn

    Scott M. Guest

    You did, but apparently this person wants us to come over and type it in for
    him/her.


    "Mark Rae" <> wrote in message
    news:%...
    > "Scott M." <> wrote in message
    > news:...
    >
    >> Make a button on your web page. Give it text of "Log out". In its
    >> server-side click event handler, simply write: Session.Abandon()

    >
    > Wish I'd thought of that... ;-)
    >
     
    Scott M., Mar 15, 2007
    #11
  12. Hi Laurahn,

    Regarding on the "close user session", I'd like to confirm the exact goal
    you want to achieve. Generally, for ASP.NET session state you have the
    following options to configure or manage it at design-time or runtime:

    1. turn on or turn off it in web.config <sessionState> element.

    #<sessionState> Element
    http://msdn2.microsoft.com/en-us/library/h6bb9cz9(VS.71).aspx

    2. You can also set "timeout" value in the above element which control the
    timespan after which the runtime will dispose a certain idle sessionstate

    3. You can control whether a certain ASPX page can access sessionstate
    through the "@Page" directive's "EnableSessionState" attribute:

    #@ Page
    http://msdn2.microsoft.com/en-us/library/ydy4x04a(VS.71).aspx

    4. As other members have mentioned, at runtime, in code, you can explicitly
    call "Session.Abandon" method in page to terminate the current session:

    #HttpSessionState.Abandon Method
    http://msdn2.microsoft.com/en-au/library/system.web.sessionstate.httpsession
    state.abandon.aspx

    If you wonder when to call it, I think it depend on your application's code
    logic, you can put the call into a page event where you want to end a
    session and clear all the data in it. If you only want to remove data, but
    do not want to terminate the session(and start a new one), you can simply
    use the "Session.RemoveAll" or "Session.Clear" to empty the sessionstate
    collectiono.

    In addition, here is a popular ASP.NET session FAQ article which mentioned
    many common tips about using sessionstate:


    #Understanding session state modes + FAQ
    http://forums.asp.net/7504/ShowPost.aspx

    Hope this also helps.

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead



    ==================================================

    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    ications.



    Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 1 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions or complex
    project analysis and dump analysis issues. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/subscriptions/support/default.aspx.

    ==================================================



    This posting is provided "AS IS" with no warranties, and confers no rights.
     
    Steven Cheng[MSFT], Mar 15, 2007
    #12
  13. Laurahn

    Nitin Sharma Guest

    To Empty Session state there are so many ways depends on requirements:
    i am taking some cases:

    1. Suppose u want to End the Particular Session state

    Session["KEY"] = null;
    Session["abc"] = null;
    OR
    Session["abc"] = "";

    2. Suppose u want to End all the Session's in application

    Session.Abandon();
    OR
    Session.Clear();

    So here u go.......


    Nitin Sharma NXS

    *** Sent via Developersdex http://www.developersdex.com ***
     
    Nitin Sharma, Mar 15, 2007
    #13
  14. Laurahn

    Nitin Sharma Guest

    To Empty Session state there are so many ways depends on requirements:
    i am taking some cases:

    1. Suppose u want to End the Particular Session state

    Session["KEY"] = null;
    Session["abc"] = null;
    OR
    Session["abc"] = "";

    2. Suppose u want to End all the Session's in application

    Session.Abandon();
    OR
    Session.Clear();

    So here u go.......


    Nitin Sharma NXS

    *** Sent via Developersdex http://www.developersdex.com ***
     
    Nitin Sharma, Mar 15, 2007
    #14
    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. Denon
    Replies:
    1
    Views:
    580
    Saravana [MVP]
    Nov 14, 2003
  2. Daniel Albisser
    Replies:
    1
    Views:
    1,080
    GaryM
    Apr 7, 2004
  3. Paul van Rossem
    Replies:
    0
    Views:
    604
    Paul van Rossem
    Apr 7, 2005
  4. S_K
    Replies:
    6
    Views:
    679
    Russell
    Dec 7, 2007
  5. Iñaki Baz Castillo
    Replies:
    7
    Views:
    871
    Iñaki Baz Castillo
    Jan 12, 2010
Loading...

Share This Page