session expiry when using sessionState mode="SQLServer"

Discussion in 'ASP .Net' started by Moe Sisko, Apr 28, 2008.

  1. Moe Sisko

    Moe Sisko Guest

    Using dotnet 2.0 sp1,

    I've got ASP.NET session state working ok in SQLServer mode, but the
    sessions never seem to expire.

    e.g if I add a timeout attribute like so :

    <sessionState mode="SQLServer"
    sqlConnectionString="Integrated Security=SSPI;data source=localhost"
    timeout="1" >

    the session doesn't seem to timeout. The timeout works fine in inProc
    session mode.

    Any ideas ?
    TIA
    Moe Sisko, Apr 28, 2008
    #1
    1. Advertising

  2. re:
    !> the session doesn't seem to timeout.
    !> The timeout works fine in inProc session mode.

    Session_End doesn't fire in SQL Server session state mode.

    Unless you're running a multiple web server scenario ( web farm ),
    when you need to keep track of user sessions in several servers,
    don't use SQL Server *or* State Server to track session state
    unless you're willing/able to take a performance hit.

    The cost of serialization/deserialization affects performance.

    In the case of State Server, the cost is about a 15% performance degradation.
    In the case of SQL Server, the cost is about a 25% performance degradation.




    Juan T. Llibre, asp.net MVP
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en espaƱol : http://asp.net.do/foros/
    ======================================
    "Moe Sisko" <null> wrote in message news:...
    > Using dotnet 2.0 sp1,
    >
    > I've got ASP.NET session state working ok in SQLServer mode, but the sessions never seem to expire.
    >
    > e.g if I add a timeout attribute like so :
    >
    > <sessionState mode="SQLServer"
    > sqlConnectionString="Integrated Security=SSPI;data source=localhost" timeout="1" >
    >
    > the session doesn't seem to timeout. The timeout works fine in inProc session mode.
    >
    > Any ideas ?
    > TIA
    >
    >
    Juan T. Llibre, Apr 28, 2008
    #2
    1. Advertising

  3. Moe Sisko

    Moe Sisko Guest

    "Juan T. Llibre" <> wrote in message
    news:...
    > re:
    > !> the session doesn't seem to timeout.
    > !> The timeout works fine in inProc session mode.
    >
    > Session_End doesn't fire in SQL Server session state mode.
    >


    Juan,

    Yes, I realise that Session_End doesn't fire in SQL Server state.

    What I meant was, I was expecting the Session data to be automatically
    cleared by SQL Server after the timeout minutes elapsed.
    e.g. if I did : Session["abc"] = 5 , then after the timeout period
    elapsed, I'm expecting : Session["abc"] to be null.

    Otherwise the ASPStateTempSessions table in the session state database will
    just keep growing. Old rows of this table doesn't seem to be getting cleaned
    up.
    Moe Sisko, Apr 29, 2008
    #3
  4. Moe Sisko

    Moe Sisko Guest

    "Moe Sisko" <null> wrote in message
    news:%...
    >
    > What I meant was, I was expecting the Session data to be automatically
    > cleared by SQL Server after the timeout minutes elapsed.
    > e.g. if I did : Session["abc"] = 5 , then after the timeout period
    > elapsed, I'm expecting : Session["abc"] to be null.
    >


    Never mind, figured it out - SQL Server Agent needs to be running. It runs a
    stored proc every minute which gets rid of expired session data.
    Moe Sisko, Apr 29, 2008
    #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. Kristofer Liljeblad
    Replies:
    0
    Views:
    591
    Kristofer Liljeblad
    Jun 30, 2003
  2. TSelvan
    Replies:
    1
    Views:
    1,766
    Natty Gur
    Jul 30, 2003
  3. Phl
    Replies:
    0
    Views:
    366
  4. John
    Replies:
    0
    Views:
    374
  5. =?Utf-8?B?RWQ=?=

    SessionState Mode=SQLServer and Session.Abandon

    =?Utf-8?B?RWQ=?=, Sep 20, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    640
    bruce barker \(sqlwork.com\)
    Sep 20, 2006
Loading...

Share This Page