• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 521
  • Last Modified:

ASP.Net 3.5 Declared Session Variables Time-out after 20 Minutes

I have an ASP.net 3.5 visual basic web application that uses form authentication.
In the web.config file the following is scripted…

<authentication mode="Forms">
      <forms loginUrl="login.aspx"
       timeout ="60" slidingExpiration ="true" />

I query an SQL database and declare several session variables when the user logs on in the code behind of the Login page. This is the code declaring the session variables from data queried from the SQL Server connection…

Dim customReader As SqlDataReader = LoginSelCommand.ExecuteReader()
        If customReader.Read() Then
            Session("UserID") = (customReader("IDNum"))
            Session("UserFName") = (customReader("FName"))
            Session("UserLName") = (customReader("LName"))
            Session("UserEmail") = (customReader("email"))
        End If

           If Not customReader.HasRows Then
            Me.InvalidCredentialsMessage.Visible = True
      FormsAuthentication.RedirectFromLoginPage(Session("UserFName"), False)
        End If

Here is the PROBLEM…
As you can see, I have the Session set to timeout at 60 minutes which works fine, however, the declared session variable always timeout at exactly 20 minutes. These declared session variables are critical to the Web app as they are used as criteria in gridviews and email communication.
When a user returns to the default login page, there are several lists in their queue that show that they have no further funtions to complete after 20 minutes has elapsed while the forms authentication is not timing out for another 40 minutes, so they are still active but being presented the wrong data.
Why would the formsAuthentic authentication mode timeout for the session work OK (60 min) and the Session variables I declare disappear after 20 minutes which if I am not mistaken is the derfault timeout clock value?
Am I missing a step in my session setup?
Very frustrated, Please Help!
  • 2
2 Solutions
demergAuthor Commented:
configuration>  <system.web>
    <sessionState timeout="30">
Alfred A.Commented:
Just adding to what @dj_alik mentioned already, you need to set the sessionState timeout in your "web.config".  If you need session timeout in 60 minutes, then you need to set timeout="60".

Check this out:

demergAuthor Commented:
Thanks Very Much!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now