问题描述
hi to all
如何在浏览器关闭或网页注销时结束用户会话?
在我的网站中,我使用会话表单登录注销(我正在使用用户名和密码),如果我点击退出它重定向到登录页面,如果我点击浏览器中的后退按钮它去上一页,这里我想放弃会话,如果点击后退按钮它不要去上一页它保持登录页面
请回复asap
提前预计
hi to all
How to end user session when browser closed or web page is logout ?
In my website i use session form login to logout(i am using username and password) ,if i click logout it redirect to login page,if i click back button in the browser it go previous page,here i want to abandon session and if click the back button it dont go to previous page it stay in login page
pls reply asap
thanx in advance
推荐答案
<![CDATA[<%@ Application Language="C#" %>]]>
<script runat="server">
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
}
void Application_End(object sender, EventArgs e)
{
// Code that runs on application shutdown
// Clear Session Data here
}
void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
}
void Session_Start(object sender, EventArgs e)
{
}
void Session_End(object sender, EventArgs e)
{
}
</script>
i希望它能解决你的问题。
i hopes it hepls u.
if(!isPostBack)
{
if(Session["AfterLogin"]!=null && Session["AfterLogin"]=="AfterLogin")
{
Response.Redirect("~/SessionExpire.aspx");
}
else
{
//Your logic for login page.
}
}
in Another page :( afterlogin page)
in Another page: (afterlogin page)
if(!isPostBack)
{
Session["AfterLogin"]="AfterLogin";
// your logic goes here.
}
i希望它可以帮到你。
i hope it helps you.
这篇关于如何在浏览器关闭或网页注销时结束用户会话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!