Wolf with sheepskin - session
-------------------------------------------------- ------------------------------ March 25,2004 Original Address: http://74.com.cn/Article/2596 .SHTML writes a slightly large-scale ASP know that the session is really easy to use, it can be used to record the data variables private by the user, which is safe and convenient. But you really know that after the session understanding, you will never dare to use this lovely and hateful object. Although the method of turning alternative is slightly troubles, he has to do this under long-term consideration. First, talk about the benefits of the session, which can be used to record the client's private data variable and will not disappear within the time range. This is really important, especially if there is a member's system must be used. Login account, time, status, and many real-time data of many records, such as the real-time data of the record, such as the shopping system records the user's shopping basket, which belongs to the private needs of each user, usually developers are used. Session recording. However, the session in the ASP is composed of cookies, and the server records data recorded in all sessions to the user's browser in a cookies. Usually the general browser will save these cookies, whenever the user picks up, when it is connected to the server again, the browser will return these cookies to the Server for processing. This is the amount of session, since it is necessary to transfer it, it is not only to eat the line bandwidth, but the effectiveness is relatively reduced, because Server must spend more resources to do initial actions such as online processing and reconfiguration of memory. Now you may think "I have to use this function, I have to sacrifice points", but this article tells the session on the one hand to teach you less; on the other hand, there is an alternative approach, followed by the same global.asa Application object. Application is also a good hand in which the temporary data is recorded, and all aspects of the capacity and usage are the same as session. However, the data it records is common, that is, any user can share variable space. Application is not like sessions, not to pass the data to the user, wait for the next online reading, it is directly recorded in the memory, relative to the SESSION. Since the Application object is public, you must first plan to plan a public area to each user, so that each user has its own area to record data to achieve the purpose of simulation session. There are two practices: 1. In the startup of Server, it is initially established and allocated to the user's memory space. It usually takes up many resources, but it also saves everywhere, it must be done everywhere. Trouble in one assignment. However, there is a limit that uses this method to limit the maximum number, because it is initialized, we can only estimate a number of memory spaces, so this method is usually used in this small program of chat room. Second, this method should be more appropriate for large applications, using dynamic allocation, when the user is online to the server to assign resources to this user.
These two simulated session programs are to mitigate the consumption of session resources, but after all, it is still not fully replaced. We still need to use a little session, at least for Server has been able to alleviate a lot of burdens. ■ The first program first we started the first program, since it was initialized when started, we must start from Global.asa: