退出时我可以停止我的会话吗 [英] ho can I stop My session when Logout
本文介绍了退出时我可以停止我的会话吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的项目中,我使用了Session在每个Page中,我使用了用于注销的超链接,
当我在页面上单击时,我将该页面重定向到另一个页面,该页面为空白.并且在侧页加载的那一页上我写了
In My Project I have used Session In each Page , I have used a hyperlink for Logout,
When I click On the page i redirect That to another Page, That page is blank. and On that page in side page load I have written
Session.Abandon();
Response.Redirect("~/Login.aspx?msg=Successfully Logout");
使用Session.Abandon();
是否很好?
但是我的问题是,现在注销时需要花费很多时间.
我该怎么办?
请帮帮我.
谢谢.
Is This good to use Session.Abandon();
But My problem Is that Now When I logout It Takes So much Time To Logout.
What Can I do?
Please Help Me.
Thanks.
推荐答案
使用Session.Clear()
足够
use Session.Clear()
that s enough
Session.Abandon()
破坏会话并触发Session_OnEnd事件.
Session.Clear()
只是从对象中删除所有值(内容).具有相同密钥的会话仍然有效.
因此,如果使用Session.Abandon()
,则会丢失该特定会话,并且用户将获得一个新的会话密钥.例如,当用户注销时,您可以使用它.
如果您希望用户保留在同一会话中(例如,如果您不希望他重新登录),请使用Session.Clear()
并重置其所有会话特定的数据.
Session.Abandon()
destroys the session and the Session_OnEnd event is triggered.
Session.Clear()
just removes all values (content) from the Object. The session with the same key is still alive.
So, if you useSession.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.
UseSession.Clear()
, if you want that the user remaining in the same session (if you don''t want him to relogin for example) and reset all his session specific data.
使用global.aspx
预定义的方法是可行的
像session_start,session_stop
use global.aspx
in that predefined methods are avilable
like session_start,session_stop
这篇关于退出时我可以停止我的会话吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文