• 全部
  • .NET Framework
  • ASP
  • Web Services
  • .NET互联网桌面应用
  • VB
  • 图表区
  • 分析与设计
  • 组件/控件开发
  • AppLauncher
  • 问答

请问Session如何判断为空,又如何清空?

denoxo 2004-10-29 09:28:05
是用Session["abc"]=null;
Session.Remove("aa");
谢谢!
...全文
126 点赞 收藏 9
写回复
9 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
joinus97 2004-10-29
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
回复
mouse159 2004-10-29
hehe
回复
denoxo 2004-10-29
Session["abc"]=null;

Session.Remove("aa");
有什么样区别
回复
zcrong 2004-10-29
up
回复
yichuan1982 2004-10-29
if(Session[""]==null)

Session.Clear()
Session.remove()
回复
rickjelly2004 2004-10-29
session.Abandon

session.remove()
回复
rickjelly2004 2004-10-29
if session("") is nothing then
回复
cocoguo 2004-10-29
Session.Remove("abc");//删除一个
Session.RemoveAll();//删除全部
回复
amendajing 2004-10-29
if(Session["abc"]!=null)
{
Session["abc"]=null;
}
回复
发帖
.NET技术社区
创建于2007-09-28

5.8w+

社区成员

.NET技术交流专区
申请成为版主
帖子事件
创建了帖子
2004-10-29 09:28
社区公告
暂无公告