Session times out too soon - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Session times out too soon

I'm attempting to use a Session variable to store user information. I've got a main login page, and once I validate their login against my database, I store their login ID in Session. On subsequent pages, I've got code like this:

IF Session("loginID") = "" THEN
Response.redirect("default.asp")
END IF

so that if a user's session times out, or somebody tries to enter the middle of the site without logging in, they're redirected to the main login page.

I haven't done anything with Session.Timeout, so the timeout should default to 20 minutes, but sometimes it seems like it only takes 3-4 minutes of inactivity for my session to timeout.

What gives?

I'm running the site on a Windows 2000 server, IIS 5. I don't have frames, but I do have some pages loaded via Javascript (i.e., window.open).

I'm about this close to recoding everything to get away from Session variables (and I know there are real reasons to do this anyway), but that's going to be such a pain in the...

Thanks.

Comments

  • lillulillu Posts: 308Member
    Give a value to the Session variable in the ASP page:

    Session.Timeout = 10

    This will set the timeout to 10 minutes. Check if timeout occurs in 10 minutes or not. This will give you an idea of where to look for the error.

    : I'm attempting to use a Session variable to store user information. I've got a main login page, and once I validate their login against my database, I store their login ID in Session. On subsequent pages, I've got code like this:
    :
    : IF Session("loginID") = "" THEN
    : Response.redirect("default.asp")
    : END IF
    :
    : so that if a user's session times out, or somebody tries to enter the middle of the site without logging in, they're redirected to the main login page.
    :
    : I haven't done anything with Session.Timeout, so the timeout should default to 20 minutes, but sometimes it seems like it only takes 3-4 minutes of inactivity for my session to timeout.
    :
    : What gives?
    :
    : I'm running the site on a Windows 2000 server, IIS 5. I don't have frames, but I do have some pages loaded via Javascript (i.e., window.open).
    :
    : I'm about this close to recoding everything to get away from Session variables (and I know there are real reasons to do this anyway), but that's going to be such a pain in the...
    :
    : Thanks.
    :

    [hr][grey]To err is human, but to really foul things up requires a computer. (Farmers Almanac)[/grey] :-)

  • johnlyjohnly Posts: 3Member
    I also faced the same problem with a site where around 400 users were hitting at the same time. The solution is that we need a better session management.
    I will suggest you to change your web.config code like this.



    Here I have changed the session state to a seperate worker process (ASP state management server).

    It is recommended to move your session into the stateserver or SQL server state management in the production environment.

    Note: You need to start the 'ASP.NET State Service' windows service on the web server in order to make this code work.

    This will solve your problem related to session getting timed out before 20 minutes

    Johnlee Sam

    : I'm attempting to use a Session variable to store user information.
    : I've got a main login page, and once I validate their login against
    : my database, I store their login ID in Session. On subsequent
    : pages, I've got code like this:
    :
    : IF Session("loginID") = "" THEN
    : Response.redirect("default.asp")
    : END IF
    :
    : so that if a user's session times out, or somebody tries to enter
    : the middle of the site without logging in, they're redirected to the
    : main login page.
    :
    : I haven't done anything with Session.Timeout, so the timeout should
    : default to 20 minutes, but sometimes it seems like it only takes 3-4
    : minutes of inactivity for my session to timeout.
    :
    : What gives?
    :
    : I'm running the site on a Windows 2000 server, IIS 5. I don't have
    : frames, but I do have some pages loaded via Javascript (i.e.,
    : window.open).
    :
    : I'm about this close to recoding everything to get away from Session
    : variables (and I know there are real reasons to do this anyway), but
    : that's going to be such a pain in the...
    :
    : Thanks.
    :

    Johnlee Sam
Sign In or Register to comment.