Selva
Selva

Reputation: 556

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

Upvotes: 8

Views: 103286

Answers (2)

Robin
Robin

Reputation: 1261

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.

Upvotes: 28

Amr Elgarhy
Amr Elgarhy

Reputation: 68952

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.

Upvotes: 1

Related Questions