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:<br>
<br>
<% session("storedarray")(3) = "new value" %><br>
<br>
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. <br>
<br>
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:<br>
<br>
—file1.asp—<br>
<%<br>
creating and initializing the array<br>
dim myarray()<br>
redim myarray(5)<br>
myarray(0) = "hello"<br>
myarray(1) = "some other string"<br>
<br>
storing the array in the session object.<br>
session("storedarray") = myarray<br>
<br>
response.redirect("file2.asp")<br>
%><br>
<br>
—file2.asp—<br>
<%<br>
retrieving the array from the session object<br>
and modifying its second element.<br>
localarray = session("storedarray")<br>
localarray(1) = " there"<br>
<br>
printing out the string "hello there."<br>
response.write(localarray(0)&localarray(1))<br>
<br>
re-storing the array in the session object.<br>
this overwrites the values in storedarray with the new values.<br>
session("storedarray") = localarray<br>
%><br>
<br>
session变量可以申请数组吗?
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » session变量可以申请数组吗?
相关推荐
-      ASP 简介
-      SQL注入天书 – ASP注入漏洞全接触
-      用.net 处理xmlHttp发送异步请求
-      asp.net创建文件夹的IO类的问题
-      如何实现ASP.NET网站个性化
-      关于ASP.NET调用JavaScript的实现
-      ASP利用Google实现在线翻译功能
-      Asp无组件生成缩略图
