Results 1 to 3 of 3

Thread: Session Variables Are Dropping Within 2 Minutes

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2012
    Posts
    5

    Question Session Variables Are Dropping Within 2 Minutes

    Hello all,

    I am currently working on an ASP.NET v4.0 project using VB Script for the server-side code. I have a number of session variables that I am using across multiple pages. My problem is that although I have set the session timeout to be 20 minutes or longer (programmatically, in Web.Config, and IIS), the Session variables are being dumped after exactly 2 minutes.

    Web.config contents:
    Code:
    <authentication mode="Forms">
          <forms loginUrl="~/Login.aspx" timeout="900"/>
    </authentication>
    Session_Start routine:
    Code:
    Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
            ' Fires when the session is started
            Session.Timeout = 1200 ' Setting to a very high number to ensure that whatever timeout value is set in IIS *should* stick
            Session("VariableNames") = VariableValues ' ... multiple values here
    End Sub
    After exactly 2 minutes (120 seconds) from the last refresh, all the values retrieved using Session("<insert variable name here>") are blank. Here are a few screen caps to show the IIS settings.

    Name:  1.png
Views: 628
Size:  28.7 KBName:  2.png
Views: 514
Size:  21.9 KBName:  3.png
Views: 612
Size:  21.1 KB

    Additionally because of this problem, I have created a generic dummy handle page called KeepSessionAlive.ashx and the following javascript is called using setInterval(KeepSessionAlive, 10000); (every 10 seconds) and I have confirmed that it is working, but the Session variables are still being dumped.
    Code:
     function KeepSessionAlive() {
        //alert('testing');
        $.post("KeepSessionAlive.ashx", null, function () {
            $("#result").append("<p>Session is alive</p>");
        });
    }
    Am I missing something? Why is it dropping my Session values? Any help or information would be greatly appreciated.

    Thanks,
    John Bergman

  2. #2
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Dunmow,Essex,England
    Posts
    898

    Re: Session Variables Are Dropping Within 2 Minutes

    set the 2 hr timeout value to 00:00:00
    Last edited by Bill Crawley; Aug 9th, 2012 at 10:23 AM.

  3. #3
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Session Variables Are Dropping Within 2 Minutes

    Quote Originally Posted by Bill Crawley View Post
    set the 2 hr timeout value to 00:00:00
    Personally, creating a never ending session is not something that I would recommend.

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width