使用javascript函数清除会话 [英] clear session using javascript function

查看:77
本文介绍了使用javascript函数清除会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,



我正在开发一个应用程序,我希望通过使用java脚本函数清除会话并将用户重定向到另一个页面。

任何人都可以帮我。



提前致谢。 : - )

Hello friends,

I am developing one application in which i want to clear session and redirect user to another page by using java script function.
Can anybody help me for same.

Thanks in advance. :-)

推荐答案





我们无法从javascript代码清除服务器端会话。



但我们可以使用xmlhttprequest或Jquery。



只需使用以下代码



Hi,

We can not clear server side session from javascript code.

but we can do with xmlhttprequest or Jquery.

just by using code like following

  function logout()
{


.post( logout.aspx?action = logout,{}, function (data){
location .href = logout.aspx;
});
}
.post("logout.aspx?action=logout",{},function(data){ location.href="logout.aspx"; }); }





在代码隐藏文件中包含以下代码进行peform注销操作





In code behind file contain following code for peform logout operation

//under pageload of logout.aspx
if(request.Querystring["action"]!=null)
{
  response.clear();
  Session.abondon();
 response.write("Success");
response.End();
}





所有最佳



All the Best


请参阅此内容,可能对您有帮助/>
https://www.owasp.org/index.php/HTTPOnly [ ^ ]
Refer this, might help you
https://www.owasp.org/index.php/HTTPOnly[^]


这篇关于使用javascript函数清除会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆