且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

用Java脚本注销

更新时间:2023-12-05 12:54:22

好,您需要清除会话Cookie,您应该在服务器端执行此操作,而不是从javascript执行.用户如何登录?
Well you need to clear the session cookie which you should do serverside and not from javascript. How does the user log in?


由于高速缓存而发生这种情况.
1.清除会话
2.清除缓存,使浏览器没有历史记录(这将使浏览器中的后退/前进"按钮变为灰色).
清除缓存的代码可以放在下面的代码中:
This happens because of cache.
1. clear the sessions
2. clear the cache such that browser has no history (this will make back/forward button in browser grayed out disabled.)
code for clearing cache can be put up in code behind as follows:
// Code disables caching by browser. Hence the back browser button
// grayed out and could not causes the Page_Load event to fire 
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.UtcNow.AddHours(-1));
Response.Cache.SetNoStore();





您可以将类似的东西添加为aspx格式:



OR

You can add somethin similar in form aspx if you want to place it there:

<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0"></meta></meta></meta>





您可以通过JavaScript清除浏览器历史记录....



OR

You can clear browser history through JavaScript....

//clears browser history and redirects url
<SCRIPT LANGUAGE=javascript> {  var Backlen=history.length;   history.go(-Backlen);   window.location.href=page url }</SCRIPT>






OR

Page.ClientScript.RegisterStartupScript(this.GetType(),"cle","windows.history.clear",true);




如您在登出事件中所说:



OR
as you say in you logout event:

protected void LogOut()   
{       
     Session.Abandon();       
     string nextpage = "Logoutt.aspx";       
     Response.Write("<script language=javascript>");             
     Response.Write("{");       
     Response.Write(" var Backlen=history.length;");       
     Response.Write(" history.go(-Backlen);");       
     Response.Write(" window.location.href='" + nextpage + "'; ");
     Response.Write("}");       
     Response.Write("</script>");   
}