清除会话变量 [英] clear the session variable

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

问题描述

我有一个Web应用程序项目,并且我在treeview中有一个注销,并且在单击注销节点时需要清除所有会话变量.我使用了Session.Abandon()和Session.Clear(),但是它对我没有用.谁能帮我?预先感谢.

I have a web application project and i have a logout in treeview and i need to clear all the session variables when logout node is clicked. I used Session.Abandon() and Session.Clear() but it didnt work for me. Can anyone help me? Thanks in advance.

推荐答案

Session.Abandon()和Session.Clear()是不同的方法.
session.clear()将清除会话值,而不是从内存中删除该会话. .Abandon()是其中的所有会话,它将从内存中删除.

可能是您的会话.放弃工作但会话未刷新,请尝试以下操作

IE设置 Toos菜单->互联网选项->设置(在浏览器历史记录下)->选择每次我访问该页面"->关闭浏览器,然后重试
Session.Abandon() and Session.Clear() are different methods.
session.clear() will clear session value not remove the session from memeory. where .Abandon() is removes all session from memory.

may be your session.abandon worked but session not refreshed, try the following

IE settings Toos Menu --> Internet options --> Setting (under browser history) --> select "Everytime i visit to the page" --> close the browser and try again


如何将会话变量设置为null?
像这样:
How about setting your session variables to null?
like so:
//clear
Session[ "id" ] = null;
Session[ "password" ] = null;

//check
if(Session[ "id" ] != null && Session[ "password" ] != null)
{
   //user is logged in
}
else
{
   //user is not logged in
}



祝您编程愉快,
Morgs



Happy coding,
Morgs


Try this
At logout
Session["sessionname"]= "";


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

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