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

Posted on 2011-05-09
Last Modified: 2012-05-11
I have an 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!
Question by:demerg

    Author Comment

    LVL 18

    Accepted Solution

    configuration>  <system.web>
        <sessionState timeout="30">
    LVL 21

    Assisted Solution

    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:

    Author Closing Comment

    Thanks Very Much!

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    Join & Write a Comment

    Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
    ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now