ASP Getting Started Tutorial-end time for control sessions

Source: Internet
Author: User
Tags session id sessions

1, using the Session.Timeout property to set the time-out period

For a user who logs on to an ASP application, if the user does not do anything else within the default time of the system, the user's session is automatically revoked when the time is set, which prevents the system from wasting resources. The TimeOut property of the Session object can be used to set "Expiration Time" when the browser's settings in the TimeOut property are formatted as:

Session.TimeOut=MaxTime

2, Instance code: (5.asp) page, this example shows how to control the end of the session.

<% @ language="vbscript" %>
<% session.timeout=60 %>
<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
Session.Abandon
Response.write "本页面被你刷新了" & Session("i") & "次。</centr>"
%>

4, the Code annotation

In this case, the time-out period for the session is set to 60 minutes, but each time the page is refreshed, it is forced to end this session by calling the Abandon method of the sessions object, starting a new session, and generating a new session identity.

To confirm this, open the IE browser window, and then enter the URL of the above page in its address bar, press F5 repeatedly to refresh the page, and you will see that the session ID is changing, but the page refresh times always show 1.

See the full set of ASP Getting started tutorials

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.