473,385 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

ASP Session Early Timeout

4
I've written a single load AJAX application that uses Session variables to store User information etc.

Upon validating the username and password entered against the values stored in a database I wither the current session ID to a a variable as:

Expand|Select|Wrap|Line Numbers
  1. Session("VSession")
  2.  
  3. On each HTTP Request, I check the session for expiration.
  4.  
  5. Function ValidateSession()      '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  6. If Session("Vsession") = Nothing then 'Session expired 
  7.     Session("State")="Expired"
  8. Else
  9.     Session("State")="Active"
  10. end if    
  11.  
  12. End Function'------------------------------------------------------                
I'm using the default Session.Timeout = 20 in the Global.asa file.

But sometimes it is just a matter of seconds and Session("VSession") is Nothing. Rarely will my session variables survive 10 minutes. Any idea would be greatly appreciated. - GrnMtn
Aug 10 '08 #1
5 3449
GrnMtn
4
Afte posting my question I realized I probably didn't explain my issue very well so here's an overview of what's happening:

1) A user loads the home page, (default,asp).
2) Upon entering the username and password, the information is authencated against the userdata in a database.
3) If the username / password are correct, then a session variable is set:
Session("VSession") = Session.SessionID
4) At this point all subsequent server client interaction is via HTTPRequest.

Expand|Select|Wrap|Line Numbers
  1. function LoadPage(RStr)
  2. {   var XMLreq = new ActiveXObject("Microsoft.XMLHTTP"); 
  3.     MLreq.open("GET", RStr, true);  
  4.     XMLreq.onreadystatechange = function()
  5.     if (XMLreq.readyState == 4) 
  6.     {   if (XMLreq.responseText.indexOf("Session Expired")!=-1)  
  7.         {  location = "../default.asp"
  8.         }
  9.             document.getElementById("DivMain").innerHTML = XMLreq.responseText;
  10.  
  11.     }
  12.     XMLreq.send(null); 
  13. }
  14.  
  15. when each HTTPRequest is received by the server I validate the session with the following function.
  16.  
  17. Function ValidateSession()     
  18. If Session("Vsession") = Nothing then 
  19.    Response.Write("Session Expired")
  20.    Response.End
  21. End if    
Hopefully this is a better explaination of what I'm trying to do. The problem is that while the Session.Timeout = 20 my sessions seem to expire at random times well short of 20 minutes. Any help would be greatly appreciated. -Dennis
Aug 11 '08 #2
jhardman
3,406 Expert 2GB
What program did you use to write your code (what is your ide)? I have heard of a bug, but it is apparently ide-dependent.

Jared
Aug 12 '08 #3
GrnMtn
4
I'm doing this in Visual Web Developer 2005. - Dennis
Aug 12 '08 #4
GrnMtn
4
I think I found the answer buried deep in the following blog:

http://blogs.msdn.com/david.wang/archive/2005/09/19/Why_do_I_lose_ASP_Session_State_on_IIS6.aspx

# re: Why do I lose ASP Session State on IIS6
Thursday, April 24, 2008 12:16 PM by John Homer
The ASP (not .Net) session timeout is stored in the ASP application configuration. This is accessed via the website properties (not the application pool) on the Home Directory tab. Click the configuration button and then select the Options tab. You may then set the ASP session timeout valus in minutes which is 20 by default. This will terminate any session afetr 20 minutes on inactivity.

Note that this is independent of the application pool settings. In fact, you don't even need an application pool to utilize this setting. For instance, you can configure IIS 6 to run in IIS 5 compatibility mode (or just use IIS 5) and then configure your ASP Application Protection (Home Directory tab in website properties) to "Low (IIS Process)" which will run the application in-process (inside the inetinfo.exe process instead of w3wp.exe or dllhost.exe). Even in this scenario, the ASP timeout setting mentioned above is still effective.

For ASP.Net you can configure the session timout in your application's web.config. Look for the following line and configure accordingly:

<sessionState mode="InProc" cookieless="false" timeout="20"/>

I'm still testing but after setting the Isolation Mode to IIS 5.0 I haven't had a unexpected session expiration in over an hour. - Dennis
Aug 12 '08 #5
jhardman
3,406 Expert 2GB
Good Info! thanks for sharing your solution.

Jared
Aug 12 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Carpe Diem | last post by:
Hello I have an aspx page that loses Session("user") value after a few minutes even after I set <sessionState mode="InProc" cookieless="false" timeout="300"> in web.config and wrote function...
4
by: DavidS | last post by:
First: There are several ways to confuse one regarding session timeout. (1) web.config - <sessionState timeout="20"> (2) IIS Manager | Internet Information Services | ServerNode | Default Web Site...
6
by: Mr m?ll | last post by:
Hi Im quite new to web programming and I'm buildning this ASP .net page. I use VS 2003 and C# + IIS 5. The page consists of a login page that leads to a frame page (with some pages, reading from...
2
by: gg | last post by:
still can't figure this out. I have timeout in web.config set to 480. That should be 8 hours, right? Yet it still seems to be timing out after a short time, (perhaps the 20 minutes still). ...
11
by: Vishal | last post by:
Hello, can anybody tell me how I can extend the session expiry time? Is it done via code or via IIS? Sorry I am new and dont know about this.
12
by: ACaunter | last post by:
Hi all, I was wondering how i could write some code which would automatically open the Login Page once the session has expired? -- AdamPC@hotmail.com
4
by: UJ | last post by:
I have a page where the user can upload a video file. As you can guess, this may take a while. Is there a way I can change the session timeout for just this one page? I would also want to change...
2
by: pintu | last post by:
Hi Friends. in my application i am facing problems in maintaining session state. I am working on asp.net 2.0. So i didnt checked the session on each page and almost the project is completed. Now...
4
by: Bishop | last post by:
ASP.NET 2.0/IIS 6/Windows 2003 I have all my session settings set to the standard 20 min. but many times the session will time out prior to 20 min. of inactivity. My questions are: 1. Is...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.