Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

remove session in javascript and jquery

we all know that we can set and get session using javascript like below:

session.setItem("name", "value");  

session.getItem("name");

I need to know how to destroy particular and all session variable in javascript.

I used google but I'm unable to get exactly what I need. Please help me to find the solution. jQuery answers are also welcome (without plugin)

Thank you in advance

like image 578
Selva Avatar asked Jun 04 '26 09:06

Selva


2 Answers

I assume this is session storage in html5, in which case you can use

sessionStorage.clear();

to remove all items in the session storage or

sessionStorage.removeItem('itemName');

to remove a specific item.

like image 159
Robin Avatar answered Jun 06 '26 22:06

Robin


clear(void):void This public method remove everything from the sessionStorage object.

https://code.google.com/p/sessionstorage/

I didn't test my self but I think it should work.

like image 33
Amr Elgarhy Avatar answered Jun 06 '26 21:06

Amr Elgarhy