ASP's let session never expire _ application Tips

Source: Internet
Author: User
Tags time limit
Others say set session.timeout=99999. This is not the same, session has the maximum time limit. I passed the test found that the maximum value of 24 hours, that is, you can most session.timeout=1440,1441 are not to have, hehe. I test the environment: win2003+iis6.0+asp3.0.

So it is impossible to make the session never expire by setting the Session.Timeout expiration time. It's a good way to write cookies, there are a lot of such tutorials on the Internet, this is no longer said! There is to keep the session of the page to set hidden iframe every once in a while (this time is less than session.timeout time) to refresh a frame in the empty page! The implementation method is as follows:
In the session page you want to keep adding:
Copy Code code as follows:

<iframe width=0 height=0 src= "/blog/sessionkeeper.asp" ></iframe>

Build a sessionkeeper.asp file under the same directory. Xml/html Copy Code
Copy Code code as follows:

<meta http-equiv= "Refresh" content= "900000;url=sessionkeeper.asp" >
<!--refresh itself every 900 seconds, in order to communicate with the server, keep session will not lose-->

This approach is still relatively long, and there is a similar approach, but he is not using meta to automatically refresh nested IFRAME methods. He was using Javascript:window.setTimeout ("functionname ()", 10000), a method of automatically calling a function in a period of time, and of course the function still had to connect an empty file. The specific methods are as follows:
Add JavaScript to copy code in the session face:
Copy Code code as follows:

<script Id=back language=javascript></script>
<script language=javascript>
function Keepsession () {
document.all["Back"].src= "/blog/sessionkeeper.asp?" Randstr= "+math.random ();
The randstr=math.random here is only to prevent the same address from being refreshed if the value of each back.src is different
Window.settimeout ("Keepsession ()", 900000); Every 900 seconds call itself
}
Keepsession ();
</script>
So the same directory to build an empty content of the sessionkeeper.asp on the file on it!

The problem is not resolved: Through the above method session to maintain should be no problem, IIS default no request to clean up the session value of 20 minutes, I set the time of each interactive service is far less than this value, but I probably spent a day more time, session or no reason for no! Depressed.

Later in the online multi-party search finally found the answer: the original IIS to protect the server, there is a "recycling" concept! The test for half a day finally have a point of general understanding (don't laugh at my food ^ ^). Let's take a look at where this "recycle" is set up.

Start IIS Manager-> application pool-> right-> property-> Recycle tab, one of the defaults is the first item: "Recycle worker process (minutes)" defaults to 1740 minutes, about 29 hours. What does he mean by that? I personally understand: after the session.timeout 1740 minutes after the automatic removal of all remaining sessions. This value can be set to a maximum of 4000000, about more than 2,700 days! I canceled it directly, no need for him to automatically recycle! The problem was finally solved.

In addition, there are several other items in this property dialog box:
The second item should be that the connected user exceeds a certain number of recoveries.
The third item is to automatically recycle at a certain time.

In the Performance tab, "Close worker processes after idle this period" is where you set the default Session.Timeout time for IIS. The default value is 20 minutes, where the same maximum value can be set to 4000000, and setting the Session.Timeout maximum value to 1440 is different in the ASP page. The setting of a value greater than 1440 here does not work, I do not test, I think it should be possible. So why is the maximum value of session.timeout in an ASP page to be as large as 1440 in the properties of IIS? Should be a protection mechanism: ASP page Session.Timeout value of which users can set, IIS but only administrators can set, the two permissions are different, so the scope of the set is different.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.