Timeout Session using Stateserver

Asked

Viewed 562 times

1

I have an application in cluster who wear the Session, to give no problem I put another machine to serve Session Server and set up the web.config as follows:

<sessionState mode="StateServer" stateConnectionString="tcpip=[IP]:42424" stateNetworkTimeout="3600" timeout="1440" />

I left the timeout in 1440 min to leave the session active for 1 day, but there are cases that the user enters the system and after min he loses the session, the TimeOut of SessionState Wouldn’t it serve precisely to not do that? and how can I detect what is causing the sessions to be lost?

  • 2

    It depends on how the user is coming and going. The session is identified by a cookie in the customer’s browser, whether it is using different browsers or whether the cookie is being lost, the session will not be identified.

1 answer

1


There are several possibilities, I will list the most common:

  1. Your server (Stateserver) is being restarted and is saving sessions in memory
  2. Your database that stores sessions is being erased (someone cleans it) with some frequency
  3. User is using incognito (anonymous) browser navigation mode
  4. User is cleaning cookies and sessions manually or browser is set to do so when close
  5. User is switching browser (session is not maintained between browsers)
  6. At some point in your code you may have a Session.Abandon() or lougout

In the global.asax you can put error handlers to take the exceptions that are not being handled and pick up some error that may not be reported or detected.


Complementing

The session can be configured differently in the authentication part and in the HTTP part, inside your web.config. I will explain. See the following example of web.config

<?xml version="1.0"?>
<configuration>
    <system.web>
        <sessionState timeout="20" mode="SQLServer" cookieless="false" sqlConnectionString="data source=servidor\SQL2012;user id=user_aspstate;password=aspstate"/>
        <authentication mode="Forms">
            <forms name="MeuAuth" loginUrl="Login.aspx" path="/" timeout="10000" protection="All"/>
        </authentication>
    </system.web>
</configuration>

Note that the authentication timeout is 10,000 minutes! The default value of this property is 30 minutes. sessionState is set to a 20 minute timeout, which is already the default value . NET sets for this property. If Forms has a lower timeout than sessionState it will happen before. And it may be that your web.config is with this little problem of different values.

  • In the code I have a Session.Abadon() even but it only kills that user’s session right?

  • @user3258 yes, just from that user, but you have to see when it’s called. Is it inside something that’s called automatically? On a link the user clicks? No global.asax? Tries to put a breakpoint on all Session.Abandon() and make sure it’s not falling there.

  • Take a look at the comlementation I put in. I remembered that detail now.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.