开发者网络 动网主机 支持论坛 邮局 帮助
当前位置:网络学院ASP技术ASP应用 → session变量中的数组如何引用
session变量中的数组如何引用
日期:2001年5月14日 作者:hooke(转) 人气:     [ ]
If you store an array in a Session object, you should not attempt to alter the elements of the stored array directly. For example, the following script will not work:

<% Session("StoredArray")(3) = "new value" %>

This is because the Session object is implemented as a collection. The array element StoredArray(3) does not receive the new value. Instead, the value is indexed into the collection, overwriting any information stored at that location.

It is strongly recommended that if you store an array in the Session object, you retrieve a copy of the array before retrieving or changing any of the elements of the array. When you are done with the array, you should store the array in the Session object again so that any changes you made are saved. This is demonstrated in the following example:

---file1.asp---
<%
'Creating and initializing the array
Dim MyArray()
Redim MyArray(5)
MyArray(0) = "hello"
MyArray(1) = "some other string"

'Storing the array in the Session object.
Session("StoredArray") = MyArray

Response.Redirect("file2.asp")
%>

---file2.asp---
<%
'Retrieving the array from the Session Object
'and modifying its second element.
LocalArray = Session("StoredArray")
LocalArray(1) = " there"

'Printing out the string "hello there."
Response.Write(LocalArray(0)&LocalArray(1))

'Re-storing the array in the Session object.
'This overwrites the values in StoredArray with the new values.
Session("StoredArray") = LocalArray
%>

(出处:chinaasp)

相关文章:
 
·披著羊皮的大野狼 - Session
·使用sqlserver来存放和取得session
·session 和 viewstate 的比较
·监测你的站点使用多少session和application的程序
·ASP中使用Session变量的优缺点
·如何取得所有的Session变量
·关于释放session的两篇文章(二)
·关于释放session的两篇文章(一)
·深入研究Application和Session对象(包括global.asa)3
·深入研究Application和Session对象(包括global.asa)2
相关软件:
 
·Sessions Applications Cookies Explorer v2.0
·简单的用户论证和SESSION的管理
说明:本站部分内容收集于网络,如有侵犯您的权益请来信告知,我们会第一时间进行处理,谢谢
 → 特别推荐
 → 热点TOP10

关于本站 | 诚聘英才 | 业务合作 | 联系我们 | 广告合作 | 收藏本站

海口动网先锋网络科技有限公司版权所有
Copyright ? 2000 - 2003 AspSky.Net
中华人民共和国电信与信息服务业务经营许可证编号 琼 ICP 020077