Value property of the Session
object provides easy to use syntax to the scripts. Through the Value property values and
objects can be set/get to/from the Contents collection.
Syntax:
Session.Value(key_name) = variable
variable = Session.Value(key_name)
Session(key_name) = variable
variable = Session(key_name)
Parameters:
key_name - string that is used as label for the
value/object being set/retrieved to/from the collection.
variable - any variable that can be converted to a value
such as number and string or object. Object being set can not be an internal scripting
object! Note (most important for the JScript programmers): If you want to save array in
the collection use safearray (often called VBArray). See remarks section for more details.
If key_name does not exist in the collection VT_NULL is returned. Most
script languages support the null values: in JScript it is the keyword
null in VBScript IsNull function can be used.
When assigning Value property automatically creates the key_name if the
key does not exist in the Contents collection.
Samples:
<% Session("UserName") = strUser %>
<%
Dim obj
Set obj = Server.CreateObject("Company.SomeObject")
Session("TheObject") = obj
%>
<%
var fso = Server.CreateObject("Scripting.FileSystemObject");
var dir = fso.GetFolder(Server.MapPath(".");
Session("LastDirectory") = dir;
%>
Remarks:
Value property manages the Contents
collection and can be called a "Contents collection helper". Remarks for the
Contents collection are true for the Value property - i.e. in the ScriptGen it is realized
using the VarDictionary class form the newObjects
collections thus it supports full collection features in difference of the Session object
in the IIS ASP.
Applies to: Session object
See also: Session.Contents, VarDictionary |