程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> ASP編程 >> ASP技巧 >> 關於釋放session的兩篇文章(一)

關於釋放session的兩篇文章(一)

編輯:ASP技巧

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


 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved