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

denoxo 2004-10-29 09:28:05
是用Session["abc"]=null;
Session.Remove("aa");
谢谢!
...全文
184 9 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
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;
}

62,243

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧