1, what is the session identification
ASP assigns a unique identification flag to each user session. When you create a session, the server generates a separate identity for each session, which is returned with a long integer data type and is saved with the user on the Web site. Use the SessionID property of the Session object to return the user's conversation identity in the following format:
Session.SessionID
One use of the SessionID property is to track the activity of the visitor. For example, to record a user-visited page in the site log, add the following script to all pages:.
2. Instance code (4.asp): This example uses the SessionID property of the Session object to display the user's conversation identity, using the script_name of the server variable to obtain the current path of the user to access the Response object AppendToLog Method adds a string to the requested Web site log file, which consists of two parts: the 1th part is the session identity, and part 2nd is the current page path. and write a simple counter program through the session collection.
<body>
<%
who = Session.SessionID
CurrentPage=Request.ServerVariables("SCRIPT_NAME")
Response.AppendTolog who & ":" & CurrentPage
Response.write "<center>你的会话标识为:" & who & "<p>"
Response.write "你当前访问的页面路径为:" & CurrentPage & "<p>"
if Session("I")="" then
session("i")=1
else
session("i")=session("i")+1
end if
Response.write "本页面被你刷新了" & Session("i") & "次。</centr>"
%>
4, the Code annotation
Open IE browser window, and then in the Address bar to enter the URL of the above page, and press F5 key to refresh the page, then open an IE browser window, and then in the Address bar to enter the page URL, and continuously press F5 key Refresh page. At this point, you see two different session identities appearing in two windows, the session identity in each window is unchanged when the page is refreshed, and the number of page refreshes in two windows is independent of each other.
5. Note: The site log file is stored in WINNTSYSTEM32LOGFILESW3SVC1, which is a set of text files with a. log extension.
See the full set of ASP Getting started tutorials