📄 asp_ref_session.asp@output=print
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>ASP Session Object</title>
<link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta name="Keywords" content="xml,tutorial,html,dhtml,css,xsl,xhtml,javascript,asp,ado,vbscript,dom,sql,colors,soap,php,authoring,programming,training,learning,beginner's guide,primer,lessons,school,howto,reference,examples,samples,source code,tags,demos,tips,links,FAQ,tag list,forms,frames,color table,w3c,cascading style sheets,active server pages,dynamic html,internet,database,development,Web building,Webmaster,html guide" />
<meta name="Description" content="Free HTML XHTML CSS JavaScript DHTML XML DOM XSL XSLT RSS AJAX ASP ADO PHP SQL tutorials, references, examples for web building." />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "../../https@ssl./default.htm" : "../../www./default.htm");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-3855518-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>
</head>
<body>
<p>From <b>http://www.w3schools.com</b> (Copyright Refsnes Data)</p>
<h1>ASP Session Object</h1>
<a href="asp_ref_application.asp"><img border="0" alt="previous" src="../images/btn_previous.gif" width="100" height="20" /></a>
<a href="asp_ref_server.asp"><img border="0" alt="next" src="../images/btn_next.gif" width="100" height="20" /></a>
<hr />
<p class="intro">The Session object is used to store information about, or change settings for
a user session. Variables stored in the Session object hold information about one single
user, and are available to all pages in one application.</p>
<hr />
<h2>Examples</h2>
<p><a target="_blank" href="showasp.asp@filename=demo_lcid">Set and return the LCID</a><br />
This example demonstrates the "LCID" property. This property sets or
returns an integer that specifies a location or region. Contents like date,
time, and currency will be displayed according to that location or region.</p>
<p><a target="_blank" href="showasp.asp@filename=demo_sessionid">Return the SessionID</a><br />
This example demonstrates the "SessionID" property. This property returns
a unique id for each user. The id is
generated by the server.</p>
<p><a target="_blank" href="showasp.asp@filename=demo_gettimeout">A session's timeout</a><br />
This example demonstrates the "Timeout" property. This example sets
and returns the timeout (in minutes) for the session.</p>
<hr />
<h2>Session Object</h2>
<p>When you are working with an application, you open it, do some changes and then
you close it. This is much like a Session. The computer knows who you are. It
knows when you start the application and when you end. But on the internet there is one
problem: the web server does not know who you are and what you do because the HTTP address doesn't maintain
state. </p>
<p>ASP solves this problem by creating a unique cookie for each user. The cookie
is sent to the client and it contains information that identifies the user. This
interface is called the Session object. </p>
<p>The Session object is used to store information about, or change settings for
a user session. Variables stored in the Session object hold information about one single
user, and are available to all pages in one application. Common information
stored in session variables are name, id, and preferences. The server creates a
new Session object for each new user, and destroys the Session object when the session expires. </p>
<p>The Session object's collections, properties, methods, and events are
described below:</p>
<h3>Collections</h3>
<table class="ex" cellspacing="0" border="1" width="100%" cellpadding="3">
<tr valign="top">
<th width="32%" align="left">Collection</th>
<th width="68%" align="left">Description</th>
</tr>
<tr valign="top">
<td><a href="coll_contents_sess.asp">Contents</a></td>
<td>Contains all the items appended to the session through a script command</td>
</tr>
<tr valign="top">
<td><a href="coll_staticobjects_sess.asp">StaticObjects</a></td>
<td>Contains all the objects appended to the session with the HTML
<object> tag</td>
</tr>
</table>
<h3>Properties</h3>
<table class="ex" cellspacing="0" border="1" width="100%" cellpadding="3">
<tr valign="top">
<th width="32%" align="left">Property</th>
<th width="68%" align="left">Description</th>
</tr>
<tr>
<td valign="top"><a href="prop_codepage.asp">CodePage</a></td>
<td valign="top">Specifies the character set that will be used when
displaying dynamic content</td>
</tr>
<tr>
<td valign="top"><a href="prop_lcid.asp">LCID</a></td>
<td valign="top">Sets or returns an integer that specifies a location or
region. Contents like date, time, and currency will be displayed according
to that location or region</td>
</tr>
<tr>
<td valign="top"><a href="prop_sessionid.asp">SessionID</a></td>
<td valign="top">Returns a unique id for each user. The unique id is
generated by the server</td>
</tr>
<tr>
<td valign="top"><a href="prop_timeout.asp">Timeout</a></td>
<td valign="top">Sets or returns the timeout period (in minutes) for the
Session object in this application</td>
</tr>
</table>
<h3>Methods</h3>
<table class="ex" cellspacing="0" border="1" width="100%" cellpadding="3">
<tr valign="top">
<th width="32%" align="left">Method</th>
<th width="68%" align="left">Description</th>
</tr>
<tr>
<td valign="top"><a href="met_abandon.asp">Abandon</a></td>
<td valign="top">Destroys a user session</td>
</tr>
<tr>
<td valign="top"><a href="met_contents_remove_sess.asp">Contents.Remove</a></td>
<td valign="top">Deletes an item from the Contents collection</td>
</tr>
<tr>
<td valign="top"><a href="met_contents_removeall_sess.asp">Contents.RemoveAll()</a></td>
<td valign="top">Deletes all items from the Contents collection</td>
</tr>
</table>
<h3>Events</h3>
<table class="ex" cellspacing="0" border="1" width="100%" cellpadding="3">
<tr valign="top">
<th width="32%" align="left">Event</th>
<th width="68%" align="left">Description</th>
</tr>
<tr valign="top">
<td><a href="ev_sess_onend_onstart.asp">Session_OnEnd</a></td>
<td>Occurs when a session ends</td>
</tr>
<tr valign="top">
<td><a href="ev_sess_onend_onstart.asp">Session_OnStart</a></td>
<td>Occurs when a session starts </td>
</tr>
</table>
<br />
<hr />
<a href="asp_ref_application.asp"><img border="0" alt="previous" src="../images/btn_previous.gif" width="100" height="20" /></a>
<a href="asp_ref_server.asp"><img border="0" alt="next" src="../images/btn_next.gif" width="100" height="20" /></a>
<p>From <b>http://www.w3schools.com</b> (Copyright Refsnes Data)</p>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -