这两个Session.Clear()和Session.Abandon()摆脱会话变量。据我所知,放弃()结束当前会话,并使得由此产生一个新的会话引起的结束和开始事件触发。
Both Session.Clear() and Session.Abandon() get rid of session variables. As I understand it, Abandon() ends the current session, and causes a new session to be created thus causing the End and Start events to fire.
有似乎preferable调用放弃()在大多数情况下,如将用户登录出去。是否有场景,我会使用清除()呢?也有很大的性能差异?
It seems preferable to call Abandon() in most cases, such as logging a user out. Are there scenarios where I'd use Clear() instead? Is there much of a performance difference?
推荐答案
Session.Abandon()
破坏了会议和 Session_OnEnd事件被触发。
Session.Clear()
只是从对象中删除所有值(内容)。使用相同的密钥会议还活着。
Session.Clear()
just removes all values (content) from the Object. The session with the same key is still alive.
所以,如果你使用 Session.Abandon()
,你失去了特定的会话,用户将获得一个新的会话密钥。当用户注销时,您可以使用它,例如。
So, if you use Session.Abandon()
, you lose that specific session and the user will get a new session key. You could use it for example when the user logs out.
使用 Session.Clear()
,如果希望留在同一个会话(如果您不希望用户重新登录为例),并重置用户所有会话的具体数据。
Use Session.Clear()
, if you want that the user remaining in the same session (if you don't want the user to relogin for example) and reset all the session specific data.
相关推荐
最新文章