在 javascript 和 jquery 中删除会话
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29648424/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
remove session in javascript and jquery
提问by Selva
we all know that we can set and get sessionusing javascript like below:
我们都知道我们可以session像下面这样设置和使用 javascript:
session.setItem("name", "value");
session.getItem("name");
session.getItem("name");
I need to know how to destroy particular and all session variable in javascript.
我需要知道如何在 javascript 中销毁特定和所有会话变量。
I used googlebut I'm unable to get exactly what I need. Please help me to find the solution. jQuery answers are also welcome (without plugin)
我使用谷歌,但我无法得到我需要的东西。请帮我找到解决方案。也欢迎 jQuery 答案(没有插件)
Thank you in advance
先感谢您
回答by Robin
I assume this is session storagein html5, in which case you can use
我假设这是html5 中的会话存储,在这种情况下您可以使用
sessionStorage.clear();
to remove all items in the session storage or
删除会话存储中的所有项目或
sessionStorage.removeItem('itemName');
to remove a specific item.
删除特定项目。
回答by Amr Elgarhy
clear(void):void This public method remove everything from the sessionStorage object.
clear(void):void 此公共方法从 sessionStorage 对象中删除所有内容。
https://code.google.com/p/sessionstorage/
https://code.google.com/p/sessionstorage/
I didn't test my self but I think it should work.
我没有测试自己,但我认为它应该有效。

