Session objects are specific for each user of your application.
This code shows how to set and to retrieve a session variable.
<html>
<head>
<title>
</title>
</head>
<body>
<%
'setting a session variable
Session("strUserName") = "Adam"
%>
The user is named:
<%
'reading a session variable
Response. Write Session("strUserName")
%>
</body>
</html>
|
This variable is available in every page the user accesses. It will expired according to the timeout property set,the default being 20 minutes.
<%
'setting the session timeout to 10 minutes
Session.timeout= 10
%>
|
If the user doesn't access the application for the given timeout value then the session has ended and the variable is no longer retained.
Never place objects in session variables. Doing so is costly on server resources and will affect the performance of your application.
A session can be ended by the following code.
<%
'end session because user has logged out the session timeout to 10 minutes
Session.abandon
%>
|
|