funk 2006-6-25 05:18
Manage conversation
It is that the user visits in once to succeed in developing one of the difficult problem of Web application program, namely during conversation, While the user jumps to rotate with the page in the page of an application program, Maintain user's information. HTTP is that one kind does not have state agreement ,That is to say Web regard as visit having nothing to do with each other come and punish some page of visited by server; The server does not keep any information visited the first once , even visit and happen before several seconds visiting at present. Just because this is planted no the characteristic that memory was visited in the past makes the application program which was written on-line catalogue , etc. very difficult, This type of application program may need to follow catalogue one that the user has chosen while jumping to rotate among different pages of the catalogue .
ASP has offered the unique scheme of a conversation information question of management. Use and at the that server produce special user ID senses of you, you can establish a intelligent application program target Session ASP, This application program discern each a piece of visiting user and collect application program follow the heads of user select or choose information that use that content wants.
ASP sets up the user ID through HTTP cookie. HTTP cookie is a little file that is stored on user's browser. So, if you are establishing application program for not supporting the browser of cookie, or the customers of you set up for accepting cookie, please don't use the conversation functions of management of ASP browser.
You can write the script run when the application program starts or finish too.
Start and finish conversation
Conversation can be started through three kinds of ways:
A new user asks and visit one URL, .asp file in this URL sign a certain application program, And Global of this application program. As a file includes Session_OnStart course.
The user has stored a value among Session targets.
The user asked for an application program .asp file, and Global of this application program. Asa's file useThe instance with target in the function land of conversation that the label is established.
If users have not asked or break any page in the application program within fixed time, Conversation will be finished automatically .The acquiescence value of this period of time is 20 minutes. Can have been through in Internet serve management machine set up " application program select" attribute change attribute the acquiescence of application program restrict to be set up Put. Should at the Web the requests of application programs of you and memory space of the server set up this value. For example, if you hope that the user who have a look around your Web application program only stay for several minutes in every page, Should shorten the acquiescence ultra duration of conversation . Pass long conversation ultra durations result in too much to exhaust the memory resources of servers of you conversation that turn on.
To a specific conversation, if you want to set up an ultra duration which is smaller than the ultra duration of acquiescence, Can set up Session target's Timeout attribute . For example, this section of scripts below set up ultra duration as 5 minutes.
<% Session.Timeout = 5 %>
You set up each greater than ones that acquiescence set up are as follows, Session.Timeout attribute determines to exceed duration .
You can finish a conversation through Abandon type of square Faxian of Session target too. However, offer each" withdraw from" button, set up the ACTION parameters of button among form.
<% Session.Abandon %>
About SessionID and Cookie
Ones that work as the first request setting of user's application program .asp on the file, ASP turns into one SessionID. SessionID by one complicated number that algorithm turn into, it only identification each user conversation. When beginning, server regard Session ID as one cookie store of the Web browsers of users in new conversation.
SessionID and key ar