当前位置: 首页 > 图文教程 > 网络编程 > ASP > 关于释放session的两篇文章(一)

ASP
ASP动态生成的javascript表单验证代码
将身份证从15位升级为18位的函数
ASP自定义函数,仿VBA中域函数DLookup
6行代码实现无组件上传
用VS2003调试ASP的方法和体会
ASP中存储过程调用的两种方式及比较
升级到2003后访问数据库发生8007007f错误的解决
ACCESS转化成SQL2000需要注意的几个问题
让ASP程序运行于非Windows平台
一些不长见的ASP调用存储过程的技巧
网站图片扫描类
一条sql 语句搞定数据库分页
在ASP中取得服务器网卡的MAC地址、DNS地址等网络信息
ASP中轻松实现变量名-值变换
用Xml2OleDb将XML文件插入到数据库
购物车中数据的存放方式
ASP数据库编程SQL常用技巧
在ASP中利用ADO显示Excel文件内容的函数
ASP+SQL Server之图象数据处理
在 Access 中使用“存储过程”

ASP 中的 关于释放session的两篇文章(一)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 45 ::
收藏到网摘: n/a

  If you are using ASP 3.0 (the version of ASP that comes with Windows 2000 / IIS 5) then you can use the following syntax:

Session.Contents.Remove "name"

where Name is the name of the Session variable you wish to remove. Removing Session variables in this way has its advantages over using the following method:

Session("Name") = Null

Namely, the above method (setting a Session variable to Null) only removes the memory associated with the Session variable itself... the Session object still maintains a reference to it, though. Each Session variables is stored in the Session object with a key/item pair, similar to the Scripting.Dictionary object. Therefore, using the Null method above, you are not removing the key from the Session Contents collection that contains the reference to the variable...

With the Remove method that we looked at first, you are removing both the key and item associated with a Session variable. There is also a RemoveAll method that can be used to scrap all of the Session variables completely:

Session.Contents.RemoveAll

Again, the Remove and RemoveAll methods are new to ASP 3.0. If you have ASP 2.0, you will need to use the Null method