【发布时间】:2011-03-17 04:50:55
【问题描述】:
我一直在使用 Session.clear() 并且我在 firecookie 中注意到该会话仍然存在。所以我开始四处搜索,发现有 4 种方法可以删除会话
Session.Remove(strSessionName); Remove an Item from Session State Collection
Session.RemoveAll() Remove all items from session collection
Session.Clear() Remove all items from session collection Note: There is no difference between Clear and RemoveAll. RemoveAll() calls Clear(), internally.
Session.Abandon() Cancels the Current Session
现在 clear 和 remove 似乎做同样的事情,但你应该使用哪一个,比如为什么使用 remove() 而不是放弃而不是 clear。
如果你使用 session.Abandon 它会杀死当前会话。 clear() 删除值的位置。
为什么您只想保留没有值的会话?为什么不把它彻底杀死?
【问题讨论】: